Computing.Net > Forums > Programming > Batch to apend Folder name to filenames

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 to apend Folder name to filenames

Reply to Message Icon

Name: spinway40
Date: May 13, 2009 at 06:03:38 Pacific
OS: Windows Vista
Subcategory: Batch
Comment:

Can anyone point me to a DOS batch that will append the folder name to all files within that directory:

ie: c:\12345 contains 60 files and I want the file names to read 1234511111.1, 1234511115.1, etc...



Sponsored Link
Ads by Google

Response Number 1
Name: Shaka
Date: May 14, 2009 at 14:59:50 Pacific
Reply:

You should save this in a different folder, or change (*) to (.txt) or whatever you are renaming. If you do put this batch in the same folder ie c\12345 you can loose the pushd.

@echo off
cls
pushd c:\12345
for %%a in (.) do set dir=%%~nxa
for %%a in (*) do call :name "%%~a"
goto :eof

:name
set file=%~1
ren "%file%" "%dir%%file%"


0
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 to apend Folder name to filenames

Batch File To delete folders www.computing.net/answers/programming/batch-file-to-delete-folders/16309.html

Move files to diff folders based on filename www.computing.net/answers/programming/move-files-to-diff-folders-based-on-filename/19872.html

FInd folder names www.computing.net/answers/programming/find-folder-names/15536.html