1.

Solve : Command prompt- altering file titles?

Answer» <html><body><a href="https://interviewquestions.tuteehub.com/tag/hi-479908" style="font-weight:bold;" target="_blank" title="Click to know more about HI">HI</a> everyone! I am brand brand new to messsing around with command prompt, though I've already accomplished a few tasks with it. I work for an office that gives us no administrative access and I can't get any additional software which makes some tasks horribly tedious. <a href="https://interviewquestions.tuteehub.com/tag/one-241053" style="font-weight:bold;" target="_blank" title="Click to know more about ONE">ONE</a> project I have coming up involves adding the word "inactive" to the <a href="https://interviewquestions.tuteehub.com/tag/front-1000768" style="font-weight:bold;" target="_blank" title="Click to know more about FRONT">FRONT</a> of thousands of PDF file names, all scattered among hundreds of folders within a single master folder. I've seen sites that suggest there is a way to use command prompt to batch  prepend file names, but so far nothing I've tried has worked. Does anyone have any suggestions as to how to add to the front of all of the PDF file names stored in a master folder?<br/><br/>Basically, I have files with numerical file names like "12345" and "123654" and I <a href="https://interviewquestions.tuteehub.com/tag/need-25476" style="font-weight:bold;" target="_blank" title="Click to know more about NEED">NEED</a> to rename all of the PDF's as "inactive 123456" or "inactive 123654" so that we keep the file on record but can instantly identify it as an old form that's not to be re-used. So I have a folder on my HD "form library" that's got <a href="https://interviewquestions.tuteehub.com/tag/lots-544791" style="font-weight:bold;" target="_blank" title="Click to know more about LOTS">LOTS</a> of subfolders in it. I need to be able to rename every PDF file in all of its subfolders.<br/><br/>Thanks for your help!<br/><br/>AliceCan you explain more your aim with an example, i mean what did you have like folder or subfolders ? and where are located all your PDF files ?<br/>What did you expected as output name of your PDF files and so on...<br/>For example if you have a PDF file named <strong>Sample.pdf</strong> ; you want to rename it as <strong>Prefix_Sample.pdf </strong> or something else ?<br/>Your <strong>Prefix = inactive</strong><br/>so the new name becomes like that <strong>inactive_Sample.pdf</strong> ?Here is a short batch that gives the names and paths of all PDF files.<br/><br/> Code: <a>[Select]</a>DIR *.PDF /B /S &gt;LIST.TXT<br/>The /B option gives a brief for of the path and file name. <br/>The /S option does all directories below the current.<br/>The LIST.TXT will have the list of all the files.<br/><br/><br/><br/>Hi  <br/>Just copy and paste this code with your <strong>notepad</strong> or <strong>notepad++</strong> and save it as <strong>Rename_PDF_Files.bat</strong> and drag and drop your master folder over it  <br/> Code: <a>[Select]</a>echo off<br/>Title Rename All PDF files in folder and its subfolders with drag and drop<br/>Mode con cols=75 lines=20 &amp; color 0E<br/>set "Drag_Dir=%~1"<br/>set "Ext=pdf"<br/>set "Prefix=inactive"<br/>IF ["%Drag_Dir%"] EQU [""] Goto:Error<br/>2&gt;nul cd "%Drag_Dir%" &amp;&amp; Call :RenamePDFfiles || Goto:Error<br/>pause<br/>Explorer "%Drag_Dir%"<br/>Exit<br/>::********************************************<br/>:RenamePDFfiles<br/>for /f "delims=" %%I in ('Dir /a-d /b /s "%Drag_Dir%\*.%Ext%" ^| findstr /I /V "%Prefix%"') do (<br/>Rem find all pdf's with a name does not containing the characters "inactive" and rename them.<br/> echo "%Prefix% %%~nxI"<br/>    Ren "%%I" "%Prefix% %%~nxI"<br/>)<br/>Exit /b<br/>::********************************************<br/>:Error<br/>Mode con cols=75 lines=5 &amp; Color 0C<br/>echo(<br/>ECHO           You must drag and drop a folder on this batch program <br/>ECHO                      to rename all the PDF files <br/>Timeout /T 10 /NoBreak &gt;nul<br/>Exit /b<br/>::*****************************************</body></html>


Discussion

No Comment Found