Solved: DOS line no longer works- it quit last week

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

cobb

Thread Starter
Joined
Aug 19, 2006
Messages
216
I have a batch file that has worked for over a year now, and it appears that as of 21 Nov 2001, one line quit working properly.
The line renames an existing file to the same name but adds the year, month, day in 20111125 format. The line is
if exist "d:\businessBkUp" ren "d:\businessBkUp" "businessBkUp%date:~10,4%%date:~4,2%%date:~7,2%"
and as I stated, worked well
Now when the batch file runs it gives

D:\>if exist "d:\businessBkUp" ren "d:\businessBkUp" "businessBkUp%date:~10,4%%date:~4,2%%date:~7,2%"
The system cannot find the path specified.

If I use the line and just rename to test, it seems to work, so it is my date entry that seems to make the command fail.

Any ideas as to what they may have changed???

I have attached the entire batch file but have changed some names (now in red) for privacy.
 

Attachments

Squashman

Retired Trusted Advisor
Joined
Apr 4, 2003
Messages
19,786
Don't you think it would have been easier to just copy and paste the code here. You could have even just renamed your BAT file to txt and upload it.
Code:
C:\DevCon\i386\devcon.exe enable @usb\vid_04E8*

sleep 10

net use /delete m: /y
net use m: "\\PCname\sharename"

d:

echo %date% >> D:\BusinessBkUpLog\time.txt
echo %time% >> D:\BusinessBkUpLog\time.txt 

m:
xcopy "M:\Documents and Settings\Folder\Desktop\Business 8Oct09\*.*" "d:\businessBkUp" /s /c /i /q /h /y
RMDIR /S /Q "D:\businessBkUp\CC Properties\ZZ Do NOT Back-up"

xcopy "M:\Documents and Settings\Folder\Local Settings\Application Data\Microsoft\Outlook\Outlook.pst" "d:\businessBkUp" /s /c /i /q /h /y\
xcopy "M:\Documents and Settings\Folder\Local Settings\Application Data\Microsoft\Outlook\archive1.pst" "d:\businessBkUp" /s /c /i /q /h /y

xcopy "M:\Documents and Settings\Folder\Local Settings\Application Data\Microsoft\Outlook\mailbox.pst" "d:\businessBkUp" /s /c /i /q /h /y
xcopy "M:\Documents and Settings\Folder\Local Settings\Application Data\Microsoft\Outlook\archive.pst" "d:\businessBkUp" /s /c /i /q /h /y

if exist "d:\businessBkUp" ren "d:\businessBkUp" "businessBkUp%date:~10,4%%date:~4,2%%date:~7,2%"

c:

echo %time% >> D:\BusinessBkUpLog\time.txt 
net use /delete m: /y

sleep 10

C:\DevCon\i386\devcon.exe disable @usb\vid_04E8*

sleep 10
pause
 

cobb

Thread Starter
Joined
Aug 19, 2006
Messages
216
:) Perhaps it would have, but some of us do not like to have to bar back and forth to see the whole line.
I have noted many replies from you Squashman and respect your knowledge here in the DOS world. Do you have any ideas on this strange one?
 

Squashman

Retired Trusted Advisor
Joined
Apr 4, 2003
Messages
19,786
:) Perhaps it would have, but some of us do not like to have to bar back and forth to see the whole line.
Yeah but now I have to flip back and forth between 3 Windows instead of two.

I can't replicate an error for that line of code. You sure it is coming from that line. I would execute the batch file from the command prompt so that you can see the whole output.
 

cobb

Thread Starter
Joined
Aug 19, 2006
Messages
216
I put a pause at the end of the batch last time I ran it. I did copy the whole action from the cmd window, but (like a newby) did not save that one. I will run the file now and post the entire result. It takes about two hours so my next post will be some time from now. ( I am going to remove some of the copy lines to shorten the time requirment.
 

cobb

Thread Starter
Joined
Aug 19, 2006
Messages
216
Squashman, I went to plan B and chopped a bunch of the XCopy from the original batch file allowing for a very fast run of the batch file. The results of the run are"


C:\>C:\DevCon\i386\devcon.exe enable @usb\vid_04E8*
USB\VID_04E8&PID_5F05\0000002CE09310500813 : Enabled
1 device(s) enabled.

C:\>sleep 10

C:\>net use /delete m: /y
The network connection could not be found.

More help is available by typing NET HELPMSG 2250.


C:\>net use m: "\\Tricias-2gig\TriciasC"
The command completed successfully.


C:\>d:

D:\>rem echo 30/11/2011 >> D:\BusinessBkUpLog\time.txt

D:\>rem echo 9:19:00.96 >> D:\BusinessBkUpLog\time.txt

D:\>m:

M:\>xcopy "M:\Documents and Settings\Tricia\Desktop\Business 8Oct09\Proposals\*.
*" "d:\businessBkUp" /s /c /i /q /h /y
7 File(s) copied

M:\>if exist "d:\businessBkUp" ren "d:\businessBkUp" "businessBkUp1/01"
The system cannot find the path specified.

M:\>c:

C:\>rem echo 9:19:02.89 >> D:\BusinessBkUpLog\time.txt

C:\>net use /delete m: /y
m: was deleted successfully.


C:\>sleep 10

C:\>C:\DevCon\i386\devcon.exe disable @usb\vid_04E8*
USB\VID_04E8&PID_5F05\0000002CE09310500813 : Disabled on reboot

Not all of 1 device(s) disabled, at least one requires reboot to complete the op
eration.

C:\>sleep 10

C:\>pause
Press any key to continue . . .


NOTE: the apparent failure of the disconnect is due to the fact that I had/have an explorer window open to the D: drive which is an external 3Tb hard drive. I accept this an an non issue.
Also, the net use delete y is in the batch file to ensure that I do not have an existing connection through some other process and the "could not be found"is a non issue at this time.
 

Squashman

Retired Trusted Advisor
Joined
Apr 4, 2003
Messages
19,786
The problem is plain as day. Look at what you are renaming it to. You can't use a slash in a file or folder name. It thinks it is a directory.

If someone changed your Regional Date and Time settings this will affect how the %DATE% variable outputs in a batch file.

At a cmd prompt type:
echo %date%
 

cobb

Thread Starter
Joined
Aug 19, 2006
Messages
216
But the original batch file does not have that slash nor is the line the same. The command line gets changed by the system when it runs. As shown in the actual batch file above, the actual line is
if exist "d:\businessBkUp" ren "d:\businessBkUp" "businessBkUp%date:~10,4%%date:~4,2%%date:~7,2%"

but when the batch file is run somehow the line gets changed by the system. If I copy the line from the batch file to a cmd window it copies properly but then gives the

C:\>if exist "d:\businessBkUp" ren "d:\businessBkUp" "businessBkUp%date:~10,4%%date:~4,2%%date:~7,2%"
The system cannot find the path specified.

error

Here is the batch file I ran that gave the last above output

C:\DevCon\i386\devcon.exe enable @usb\vid_04E8*
sleep 10
net use /delete m: /y
net use m: "\\Tricias-2gig\TriciasC"
d:
rem echo %date% >> D:\BusinessBkUpLog\time.txt
rem echo %time% >> D:\BusinessBkUpLog\time.txt
m:
xcopy "M:\Documents and Settings\Tricia\Desktop\Business 8Oct09\Proposals\*.*" "d:\businessBkUp" /s /c /i /q /h /y
if exist "d:\businessBkUp" ren "d:\businessBkUp" "businessBkUp%date:~10,4%%date:~4,2%%date:~7,2%"
c:
rem echo %time% >> D:\BusinessBkUpLog\time.txt
net use /delete m: /y
sleep 10
C:\DevCon\i386\devcon.exe disable @usb\vid_04E8*
sleep 10
pause
 

Squashman

Retired Trusted Advisor
Joined
Apr 4, 2003
Messages
19,786
Could you please show me the output from the %DATE% variable from the cmd prompt
echo %date%
 

Squashman

Retired Trusted Advisor
Joined
Apr 4, 2003
Messages
19,786
So do you see the problem now.

Now do this from the command line.

echo %date:~10,4%
echo %date:~4,2%
echo %date:~7,2%

Trying to make you realize what happened. I already told you what the culprit was. Your Regional Date settings were changed on your PC .
 

cobb

Thread Starter
Joined
Aug 19, 2006
Messages
216
Thanks Squashman. You now have my full permission to kick my stupid butt around the block once or twice. My new line is
if exist "d:\businessBkUp" ren "d:\businessBkUp" "businessBkUp%date:~6,4%%date:~3,2%%date:~0,2%"
and it now works as it should. I admit that I completely did not let the fact that I changed the format click as to the reason it did not work. Obviously with the new format my old command was entering slash marks which were taken as directory enteries.
Thanks again for pointing out what my old eyes could not see.
Best to you and all at Techguy
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top