Copy Files + Append Date

Microsoft Windows xp professional w/serv...
January 11, 2010 at 11:02:48
Specs: Windows XP
I have a small batch file ..that is copying png files from Dest. A to Dest. B

For some reason I'm getting:

The Syntax of the command is incorrect...
The Syntax cannot find specified path...

Any ideas what I missed ?

net use \\xxxxxxxx /user:xxxx xxxx
net use g: \\xxxxx\w

@echo off

Set Day=%Date:~-7,2%
Set Month=%Date:~-10,2%
Set Year=%Date:~-2,2%

If exist %2 goto End
MD %2

:End
For /F "tokens=1,2 delims=." %%A in ('DIR \png\*.png/b') do (
copy "g:\%%A.%%B" "c:\png2\%%A%Month%-%Day%-%Year%.%%B")


See More: Copy Files + Append Date

Report •


#1
January 11, 2010 at 12:20:47
i think the "tokens" part is parsing a null from 'dir/b' into %%b,
but i can't be sure as i don't know what your filenames look like (they may have dots in them other than the extension)
since you know in advance that the extension is .png, maybe do away with the parsing, just get the whole shebang:
For /F "tokens=* delims=" %%A in ('DIR \png\*.png/b') do (
copy "g:\%%A" "c:\png2\%%~nA%Month%-%Day%-%Year%.png")

if this doesn't pan out, try putting echos into your original code to see what %%A and %%B look like:
For /F "tokens=1,2 delims=." %%A in ('DIR \png\*.png/b') do (
echo.a:[%%A] b:[%%B]
pause
copy "g:\%%A.%%B" "c:\png2\%%A%Month%-%Day%-%Year%.%%B")


Report •

#2
January 11, 2010 at 12:52:50
Updated it ... same msgs

@echo off

Set Day=%Date:~-7,2%
Set Month=%Date:~-10,2%
Set Year=%Date:~-2,2%

If exist %2 goto End
MD %2

:End
For /F "tokens=* delims=" %%A in ('DIR \png\*.png/b') do (
copy "g:\%%A" "c:\png2\%%~nA%Month%-%Day%-%Year%.png")

----------


C:\Documents and Settings\All Users\Desktop\Scripts>For /F "tokens=* delims=" %A
in ('DIR \png\*.png/b') do (
echo.a:[%A] b:[%B]
pause
copy "g:\%A" "c:\png2\%~nA01-11-10.png"
)
File Not Found


copy g:\untitled.png c:\ok\

Simple command like this works without problem..
Back to the name I would like to copy any files with *.png extension


Report •

#3
January 11, 2010 at 14:55:25
oh, i think i might see the issue:
For /F "tokens=* delims=" %%A in ('DIR \png\*.png/b') do (
copy "g:\%%A" "c:\png2\%%~nA%Month%-%Day%-%Year%.png")

this does a list of directory \png\*.png, (drive c:, presumably) but it is trying to copy that name from the host (g:), so two different directories are being used. If there is a file in c:\png that does not exist in g:\ then the script will fail. I don't know if, or how, these two different directories are being synchronized, or if this doubtful operation is even what you intended (list from c:\png applied to directory of g:\ to copy back to c:\png2\).
maybe you intended this?

for... in ('DIR g:\png\*.png/b') do (
copy "g:\png\%%A" "c:\png2\%%~nA01-11-10.png"
)

or: 'DIR g:\*.png/b' ... copy "g:\%%A" "c:\png2\..."
at any rate, try and let me know exactly what you are trying to accomplish. i get the gist of it, but not enough to know what your intention is. these paths (to, from,) need to be very explicit and consistant or else "file not found" and :(


Report •

Related Solutions

#4
January 11, 2010 at 15:05:12
Source files are in root of g:\\ and they need to be copied to
c:\\path_1sk\2\png

Thank You


Report •

#5
January 11, 2010 at 15:13:21
ok, then i think you need this one:
'DIR g:\*.png/b' ... copy "g:\%%A" "c:\png2\..."
(like this:)

For /F "tokens=* delims=" %%A in ('DIR g:\*.png/b') do (
copy "g:\%%A" "c:\png2\%%~nA%Month%-%Day%-%Year%.png")

assuming that when you say "root of g:" you mean the subdirectory of where you directed the driveletter up top:
(directory or drive referenced as "w")
net use g: \\xxxxx\w



Report •

#6
January 11, 2010 at 15:45:31
net use \\xxxxxxxx /user:xxxx xxxx
net use g: \\xxxxx\w

why did you put a drive g in the net use?
is drive g in your pc or on other network?

try removing the
g:
in
net use g: \\xxxxx\w

-atashinchi


Report •


Ask Question