Computing.Net > Forums > Programming > Batch file to rename file(s) in dir

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch file to rename file(s) in dir

Reply to Message Icon

Name: AndyB
Date: September 20, 2005 at 02:23:31 Pacific
OS: Win 2000
CPU/Ram: n/a
Comment:

I need a batch file to rename the contents of a directory and then move the file to another directory (archive). The format of the files are 123456.edi and they need to be TCOL123456.edi. I've no experience with batch files so any help or solutions are greatly appreciated. There could be one or many files in the directory.

Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: AndyB
Date: September 20, 2005 at 02:48:20 Pacific
Reply:

Solved it myself - should have been more patient. I used:

for %J in (*.edi) do move %~NJ.edi c:\mydir\TCOL%~NJ.edi

Works fine, now I have got to get my EDI software to run it as a batch file!


0

Response Number 2
Name: Mechanix2Go
Date: September 20, 2005 at 02:51:44 Pacific
Reply:

Try this:

:::::::::::::::::::::
:main

for %%E in (*.edi) do call :mover %%E
goto :eof

:mover

copy %1 archive\TCOL%1 > nul
del %1
goto :eof
::::::::::::::::::

Note that this assumes the edi files are in the current directory and that the archive directory is immediately below.

HTH



If at first you don't succeed, you're about average.

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch file to rename file(s) in dir

XP batch script to rename files www.computing.net/answers/programming/xp-batch-script-to-rename-files/14608.html

Batch Script To Rename File www.computing.net/answers/programming/batch-script-to-rename-file/16798.html

Automated batch-file renaming www.computing.net/answers/programming/automated-batchfile-renaming/13367.html