Howto: Renaming of files in a folder

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
haggy
Posts: 11
Joined: 24 May 2018 03:39

Howto: Renaming of files in a folder

#1 Post by haggy » 29 Mar 2021 09:09

Hi, I want to rename all the files in a folder by removing substring of the files name.

1. i want to remove all the "[NLRC]steed]" and "[NLRC]]teed]" from the files name
2. Find below the image of the file names in the folder.

Volume in drive C has no label.
Volume Serial Number is 9436-4BDD

Directory of C:\Users\Hakeem\Desktop\vault25

19/03/2021 06:45 pm <DIR> .
19/03/2021 06:45 pm <DIR> ..
19/03/2021 06:38 pm <DIR> new
17/03/2021 01:59 pm 478,079 [NLRC]steed] Base Platform Evaluation against GLI-19.pdf
17/03/2021 02:00 pm 700,722 [NLRC]steed] Gaming System - English.pdf
17/03/2021 02:06 pm 496,408 [NLRC]steed] GLI-19 Chapter 5 ISMS audit.pdf
11/11/2020 05:03 pm 157,346 [NLRC]steed] Letter of Undertaking.pdf
17/03/2021 02:02 pm 130,440 [NLRC]steed] Network Diagram WANow.pdf
17/03/2021 02:05 pm 1,016,456 [NLRC]steed] System Architecture Diagram.pdf
17/03/2021 01:59 pm 478,079 [NLRC]]teed] Base Platform Evaluation against GLI-19.pdf
17/03/2021 02:00 pm 700,722 [NLRC]]teed] Gaming System - English.pdf
17/03/2021 02:06 pm 496,408 [NLRC]]teed] GLI-19 Chapter 5 ISMS audit.pdf
11/11/2020 05:03 pm 157,346 [NLRC]]teed] Letter of Undertaking.pdf
17/03/2021 02:02 pm 130,440 [NLRC]]teed] Network Diagram WANow.pdf
17/03/2021 02:05 pm 1,016,456 [NLRC]]teed] System Architecture Diagram.pdf
12 File(s) 5,958,902 bytes
3 Dir(s) 7,068,282,880 bytes free

C:\Users\Hakeem\Desktop\vault25> copy * %*:~12%

Thanks.

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Howto: Renaming of files in a folder

#2 Post by aGerman » 29 Mar 2021 11:37

Command line in a cmd prompt:

Code: Select all

for %i in ("[NLRC]*.pdf") do @for /f "tokens=1*" %j in ("%~i") do @ren "%~i" "%~k"
In a Batch script you would have to double all percent signs.

Steffen

haggy
Posts: 11
Joined: 24 May 2018 03:39

Re: Howto: Renaming of files in a folder

#3 Post by haggy » 31 Mar 2021 04:39

Thank you very much for the resque.

Post Reply