Swapping entire files

Javascript renaming examples. Javascript renaming is supported in version 3 or newer.

Swapping entire files

Postby mogex » Sun Jul 10, 2016 7:03 am

So I want to swap file names in a folder of like all "x.txt" files into "y.txt" files and then change the "y.txt" files into "x.txt" so at the end of the rename I would have "x.txt (formerly y.txt) and y.txt (formerly x.txt)" Would that be possible?
mogex
 
Posts: 2
Joined: Sun Jul 10, 2016 6:51 am

Re: Swapping entire files

Postby therube » Sun Jul 10, 2016 1:55 pm

Why not move all x.txt into a new directory, say 2bnewlyY.
Then rename all 2bnewlyY/x.txt to 2bnewlyY/y.txt.

And rename all {existingdir}/y.txt to x.txt.

Then move all 2bnewlyY/y.txt back into {existingdir}.
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm

Re: Swapping entire files

Postby mogex » Sun Jul 10, 2016 3:47 pm

That is what I was doing but I would hope that there is an automatic way of doing it that doesn't allow human error cause the file names are confusing and the files to swap are many.

Edit: actually I could do it with 2 renames if I could access how the program changes duplicates ... like move all x.txt in y.txt then select all the files and make it so duplicates just get changed to x.txt instead of y_1.txt
mogex
 
Posts: 2
Joined: Sun Jul 10, 2016 6:51 am


Return to Javascript Renaming