

InterviewSolution
Saved Bookmarks
1. |
Solve : Batch to rename multiple files...? |
Answer» <html><body><p>I have a number of folders named <a href="https://interviewquestions.tuteehub.com/tag/using-1441597" style="font-weight:bold;" target="_blank" title="Click to know more about USING">USING</a> a yyyymmdd format, i.e., 20100419. <br/><br/>Inside each folder I have anywhere from 40 to 75 files and the individual file names are used in nearly every folder.<br/><br/>What I need is a batch file that will prepend the folder name (20100419) followed by a <a href="https://interviewquestions.tuteehub.com/tag/period-246409" style="font-weight:bold;" target="_blank" title="Click to know more about PERIOD">PERIOD</a> to the front of every file name in each folder.<br/><br/>Can anyone <a href="https://interviewquestions.tuteehub.com/tag/help-239643" style="font-weight:bold;" target="_blank" title="Click to know more about HELP">HELP</a>? Quote from: NyteOwl on April 19, 2010, 01:01:01 PM</p><blockquote>I have a number of folders named using a yyyymmdd format, i.e., 20100419. <br/><br/>What I need is a batch file that will prepend the folder name (20100419) followed by a period to the front of every file name in each folder.<br/></blockquote> <br/>dir /b > oldname.txt<br/><a href="https://interviewquestions.tuteehub.com/tag/c-3540" style="font-weight:bold;" target="_blank" title="Click to know more about C">C</a>:\20100419>type newname.bat<br/> Code: <a>[Select]</a>echo off<br/>set /p fold=%1<br/>for /f "delims=" %%i in (oldname.txt) do (<br/>copy %%i %fold%%%i )<br/>rem rename %%i %fold%%%i<br/>rem del %%i )<br/>C:\20100419>newname.bat 20100419<br/>20100419<br/> 1 file(s) copied.<br/> 1 file(s) copied.<br/> 1 file(s) copied.<br/> 1 file(s) copied.<br/> 1 file(s) copied.<br/><br/>C:\20100419>dir<br/> Volume in drive C has no label.<br/> Volume Serial Number is 0652-E41D<br/><br/> Directory of C:\20100419<br/><br/>04/24/2010 04:32 PM .<br/>04/24/2010 04:32 PM ..<br/>04/24/2010 04:06 PM 9 20100419file1.txt<br/>04/24/2010 04:06 PM 9 20100419file2.txt<br/>04/24/2010 04:06 PM 9 20100419file3.txt<br/>04/24/2010 04:06 PM 9 20100419file4.txt<br/>04/24/2010 04:07 PM 9 20100419file5.txt<br/>04/24/2010 04:06 PM 9 file1.txt<br/>04/24/2010 04:06 PM 9 file2.txt<br/>04/24/2010 04:06 PM 9 file3.txt<br/>04/24/2010 04:06 PM 9 file4.txt<br/>04/24/2010 04:07 PM 9 file5.txt<br/>04/24/2010 04:31 PM 139 newname.bat<br/>04/24/2010 04:29 PM 55 oldname.txt<br/> 12 File(s) 284 bytes<br/> 2 Dir(s) 300,677,402,624 bytes free<br/><br/>C:\20100419>1. Hi Greg!<br/>2. I think you need to <a href="https://interviewquestions.tuteehub.com/tag/read-619994" style="font-weight:bold;" target="_blank" title="Click to know more about READ">READ</a> the question again.<br/>Thanks for the responses, but I got the job done with an inexpensive app called Rename Maestro. <br/></body></html> | |