.bat help copy move rename

Microsoft Windows xp professional w/serv...
June 24, 2010 at 16:29:06
Specs: Windows XP
Currently I manually copy a file from one network location to another and rename it. I have tried to do a little research to figure out how to do it via batch, but kept coming up short. I need to move file in \\1st\loc to \\2nd\loc. Here's the catch though... there are many files, it's an auto generated file that creates 2 files at the same time such as "file1CurrentDate.dat" and "file2CurrentDate.dat". So I can't just copy the newest file. Any ideas or suggestions would be greatly appreciated, and if I did not do the whole post right, I am sorry this is my first post here.

See More: .bat help copy move rename

Report •


#1
June 24, 2010 at 16:50:50
Oh forgot to mention file1CurrentDate.dat moves from \\1st\loc to \\2nd\loc and gets renamed TITLE_file1CurrentDate.dat

Report •

#2
June 25, 2010 at 09:03:54
is "CurrentDate" actually today's (ie, current) date?
If so, can you give an example so we can see the format of the date in question?

Report •

#3
June 25, 2010 at 12:21:25
DISCLOSURE06172010.DAT gets moved to another folder and gets renamed NAME_DISCLOSURE06172010.DAT

Report •

Related Solutions

#4
June 25, 2010 at 17:00:00
@echo off & setlocal enabledelayedexpansion
for /f "tokens=2-4 delims=/ " %%a in ("%date%") do move \\1st\loc\disclosure%%a%%b%%c.dat \\2nd\loc\name_disclosure%%a%%b%%c.dat

Report •

#5
June 25, 2010 at 17:53:38
Hey thanks for the help... unfortunately it is not working. I believe it is because the 2nd loc has one of the directories named \Name New\ ... would this cause an issues I'm assuming?

Report •

#6
June 25, 2010 at 18:10:21
yes. (sigh - spaces AGAIN!!!)
@echo off & setlocal enabledelayedexpansion
for /f "tokens=2-4 delims=/ " %%a in ("%date%") do move "\\1st\loc\disclosure%%a%%b%%c.dat" "\\2nd\loc\name_disclosure%%a%%b%%c.dat"
::----- end
try it with the quotes around both source and dest paths as shown.


Report •

#7
June 25, 2010 at 18:21:30
First thig: You are fantastic... it works like a charm.

Second: I was running into this last time I tried making this... it's nothing big, but it is asking if it is a directory or a file... is there any way to auto select file? I don't want to accidentally choose directory and mess it all up.

Also I do apologize for not realizing that there was a space in the directory.


Report •

#8
June 25, 2010 at 19:13:42
no problem, I wasn't frustrated about your post - i should have had the paths quoted to begin with, as standard procedure.
My frustrations - It's a Microsoft thing about spaces.
I have never had "move" to ask me that dialogue - only xcopy.
If the "new" filename doesn't end in "\", move (in my experience) would assume it was a file.
at risk of exposing my complete ignorance, could you give a sample of the dialogue? You might be able to pipe a "F" into
the dialogue to satisfy it, but usually stdin is ignored in low-level commands dialogues.

Report •

#9
June 25, 2010 at 19:33:39
That's right I changed move to xcopy because it wasn't working, before... I actually need the origional to stay put, so I was able to just use copy, and now everything is working just fine. Thank you for all of your help!!!

Report •


Ask Question