Computing.Net > Forums > Programming > Copy + Rename in DOS

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.

Copy + Rename in DOS

Reply to Message Icon

Name: gav
Date: September 8, 2004 at 03:07:29 Pacific
OS: WIn 2000
CPU/Ram: P4
Comment:

I'm not sure how much of this is possible in DOS but any help would be appreciated.

I have a folder with several thousand files all named aaaa_bbbbbb#bbbbbb_yyyymmddhhmmss.sum, where aaaa is a 4 digit number and bbbbbb is a 6 digit number and the last bit is a date/time stamp.

What I'm trying to do is copy all the files with a certain value for 'bbbbbb' (there will be multiple files that match this) to another folder and remove the 'aaaa_' from the start of the name.

Its been years since I've even looked at DOS so I have no idea where to begin. Any help would be great.

Thanks




Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: September 8, 2004 at 03:37:19 Pacific
Reply:

Just set up the following two lines batch, name it MyCopy.bat and type MyCopy From_Folder To_Folder Number (e.g. MyCopy C:\MyDir C:\NewDir\SubDir 567980), blanks not allowed in folder's name.

@Echo Off

For /F "tokens=1,* delims=_" %%A in ('Dir /B %~f1\????_%3*.sum') Do (
Copy %~f1\%%A_%%B %~f2\%%B)

By the way that is NT-kernelk scripting as there is no DOS at all in Win 2K/XP, only an emulator.

If anything goes wrong or you need more support, post again.



0

Response Number 2
Name: gav
Date: September 8, 2004 at 04:05:56 Pacific
Reply:

Thats exactly what we need. Thanks.


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: Copy + Rename in DOS

Copy/Rename in DOS with wildcards www.computing.net/answers/programming/copyrename-in-dos-with-wildcards/17809.html

COPY command in DOS www.computing.net/answers/programming/copy-command-in-dos/11421.html

Read lines from .txt file in DOS? www.computing.net/answers/programming/read-lines-from-txt-file-in-dos/15219.html