0

I need to rename a group of .pdf files In the \Source folder I have the files:

bbbbbbbbb-56.pdf
vduysdvss-60.pdf
sdvbdsbvv-80.pdf

I have to rename them in the \Destination folder like this:

11111111-bbbbbbbbb-ggg-hhh-56-dddd.pdf
11111111-vduysdvss-ggg-hhh-60-dddd.pdf
11111111-sdvbdsbvv-ggg-hhh-80-dddd.pdf

so I need to insert some fixed parts:

  • before the name
  • in the middle of the name
  • at the end of the name.

Using the command:

cd \Source
copy "\Source" "\Destination"
cd \Destination
ren *.pdf 11111111-?????????-ggg-hhh???-dddd.*

the result is: 11111111--56-ggg-hhh-dddd.pdf

the bbbbbbbbb string disappears

can you help me?

Thanks

neotrojan
  • 69
  • 7
  • so you want to rename the files names in destination folder right? so for that you can copy those files in /Destination folder from /Source folder and then you can use the command : To rename multiple files, use this command syntax and press Enter: ren *.ext1 ???-new_filename_part.* – deepakbhavale67 Feb 16 '19 at 07:24
  • can you give me a specific example ?. Thank you – neotrojan Feb 16 '19 at 07:31

1 Answers1

0

By using the following command Copy the files from Source to Destination :

copy "/Source_folder" "/Destination_folder"

Go in /Destination folder

cd "/Destination_folder"

And then ren the file names by the following command :

ren *.pdf ???-new_filename_part.*

(The question mark (?) is also a wildcard, but it represents a character of the original file name. So, in the syntax, we're using three question marks, which means that the output file name will include the first three characters of the original file (which works as a unique identifier to avoid duplication)

(According to your logic you can change the new filenames by using some RegExpressions or some variables)

deepakbhavale67
  • 347
  • 5
  • 13
  • I tried this: cd \Source copy "\Source" "\Destination" cd \ Destination ren *.pdf 11111111-?????????-ggg-hhh???-dddd.* ------------ but the destination file becomes: 11111111--56-ggg-hhh-dddd ----------- the file must instead become: 11111111-bbbbbbbbb-ggg-hhh-56-dddd.pdf – neotrojan Feb 16 '19 at 08:26
  • Please read the notes which I have added in circle round brackets – deepakbhavale67 Feb 16 '19 at 08:38
  • can you give me more info on RegExpressions? – neotrojan Feb 16 '19 at 08:47
  • @user7419258 please go to the [page](https://stackoverflow.com/questions/45809295/batch-file-read-file-names-from-a-directory-and-store-in-array) will be able to add the file names in array and further processing – deepakbhavale67 Feb 16 '19 at 09:02
  • unfortunately it is not clear to me the help that can give me the page you indicated – neotrojan Feb 17 '19 at 05:27