Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.8K Views
|
7 Replies
|
1 Total Like
View groups...
Share
Share this post:

Renaming multiple files

Posted 10 years ago

How can I rename some specific files in the directory to some other specific ones?

POSTED BY: fary farfar
7 Replies
Posted 10 years ago

Thanks, still not working. But if you could give a general code for the following purpose, I'd appreciate. "Taking 20 files and rename all of them in an order. For indtance 1.jpg, 2.jpg, 3.jpg, ... , 20.jpg renaming to 21.jpg, 22.jpg, ... , 40.jpg"

POSTED BY: fary farfar

You could use for loops with indices, or similarly Do loops, or While structures or perhaps Table. But far easier is to use MapThread in this case:

fns = ToString[#] <> ".jpg" & /@ Range[1, 20]
newfns = ToString[#] <> ".jpg" & /@ Range[21, 40]
MapThread[RenameFile, {fns, newfns}]

This will apply the function RenameFile to each pair from the variables fns and newfns.

POSTED BY: Sander Huisman
Posted 10 years ago

There are 19 files to be renamed.

POSTED BY: fary farfar

Please post it as code next time, not as an image.

Concatenation of strings it not done like that. The <> should be between strings. Please fix your syntax:

"DSC_" <> number <> ".tiff"
POSTED BY: Sander Huisman

Have you tried the documentation and looking for "rename file", first hit: https://reference.wolfram.com/language/ref/RenameFile.html

POSTED BY: Sander Huisman
Posted 10 years ago

I tried this one. But I want to apply it to multiple files. I tried to use multiple FOR loops (The Nested Loops), but I couldn't manage it.

POSTED BY: fary farfar

Maybe you can provide us with what you have tried, we can't read your thoughts (yet)...

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard