View Single Post
 
Old 03-01-2016, 08:07 PM
Dave T Dave T is offline Windows 7 64bit Office 2007
Advanced Beginner
 
Join Date: Nov 2014
Location: Australia
Posts: 66
Dave T is on a distinguished road
Default

Hello Paul,

I appreciate your reply.

I have never really had much to do with batch processing language either, but I found some examples that I was able to modify to suit my needs, although it probably can be done better.
The following adds ' - Capacity Calculations' before the .pdf extension, whilst retaining the original file name:

Code:
 
@ECHO OFF
REN *.pdf *.
REN *. *" - Capacity Calculations".
REN *. *.pdf
To sort the various PDF's I have had to pad the numbers out so there are five digits after the PN prefix. Again I found an example I was able to modify:

Code:
@echo off
setlocal enableextensions enabledelayedexpansion
rem iterate over all PDF files:
for %%f in (*.pdf) do (
    rem store file name without extension
    set FileName=%%~nf
    rem strip the "PN"
    set FileName=!FileName:PN=!
    rem Add leading zeroes:
    set FileName=00000!FileName!
    rem Trim to only four digits, from the end
    set FileName=!FileName:~-5!
    rem Add "PN" and extension again
    set FileName=PN!FileName!%%~xf
    rem Rename the file
    rename "%%f" "!FileName!"
)
There probably are better methods out there but these two batch files get me through.

I will mark this post as solved, but am still hoping someone can show me a better way.

Regards,
Dave T

Last edited by Dave T; 03-01-2016 at 08:20 PM. Reason: Tying to find Solved button
Reply With Quote