Renaming pdf files to include the parentfolder name as the prefix, and including a unique suffix

Lamington2m2

Please can you help. How can I rename pdf files to include the parentfolder name as the prefix, and adding DRAFT as a suffix?

For example, for parent folder name \ABCDEF:

  • xyc123.pdf
  • fgh456.pdf

I would like it to look like this \abcdef:

  • abcdefDRAFT.pdf
  • abcdefDRAFT.pdf

Each pdf is always unique, and each folder is always unique.
I just need the corresponding .pdfs in each folder to match the folder name.

I am new to scripting, and I would like to write and run the script using notepad
(I am not able to download any 3rd party software). Thank you.

It Wasn't Me

For command line in same folder (top-level folder tree):


cd /d "c:\folder_target\" & for /f tokens^=* %i in ('dir/b/s/a:-d')do ren "%~fi" "%~niDraft%~xi"

For bat/cmd file:


@echo off 

cd /d "c:\folder_target\"
for /f tokens^=* %%i in ('dir/b/s/a:-d')do ren "%%~fi" "%%~niDraft%~xi"


Additional resources:

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Renaming multiple files in bash by removing prefix and suffix containing special characters %?=

Renaming files to the prefix and the middle portion of the file name

Renaming files to add a suffix

sed include files with no suffix

name prefix and suffix removal SAS

How to replace word with unique prefix and suffix?

Including #include files at the end

Renaming environment variables by changing variable name prefix

Renaming files by using a prefix from text file

Skipping files with a given prefix when renaming

Renaming the oldest file in pairs of files with the same prefix

renaming a list of pdf files with for loop

How to add a suffix (or prefix) to each column name?

Renaming multiple files with same name

Merge prefix and suffix from 2 files

Copy files with match prefix AND suffix with shell script

Copy and rename files adding a dynamic prefix/suffix

renaming images to include creation date in name

Bulk renaming of camelcase files to include spaces

How to include a file in two files (including main) in rust and directly use its namespace name in both files?

Including files in Julia: @everywhere include

Suffix to prefix and prefix to suffix in R

Conditional renaming of multiple files from multiple subfolders based on a list of prefix

Renaming Bulk files and changing certain prefix and raring them

Renaming files by their folder's folder name on linux

renaming all files with similar structure to same name

Renaming files with the same name using sequential numbers?

Renaming multiple files depending on current name

Renaming multiple files by rearranging the original file name