how to batch copy and paste filenames

Hi, I have 500 files I need to have the exact same filename as different set of 500 files .


The files are different (they are all .png files), but I need the filenames to be the same.


Any idea how to streamline this process (versus the manual copy + paste of each file individually)?

iMac 27″, macOS 12.5

Posted on Sep 8, 2022 06:43 AM

Reply
Question marked as Top-ranking reply

Posted on Sep 8, 2022 08:46 AM

The operating system will restrict you to a unique filename per folder unless you want to add generation sets (filename_001.png, ..., filename_500.png) to the naming process. You cannot have 500 identically named files in the same folder.

9 replies

Sep 8, 2022 10:13 AM in response to Tiv_Z_

You mentioned folder 1 containing the non-alphanumeric characters and folder two without them, so I was led to believe you wanted those characters removed when copying from folder 1 to folder 2.


You could do this, provided you are in the Terminal and source A and destination folder B are on the same level:


mkdir -p B
ditto A B/


This will copy all of the files in A folder into the B folder, without recreating folder A in B. This will be very fast and preserve the original filenames and any extended attributes that may be on them.


Sep 8, 2022 10:32 AM in response to Tiv_Z_

Ditto will duplicate the files (not just their names) to the destination folder. Are you now inferring that you want just the filenames duplicated as zero content filenames to the destination folder? The following will place zero-length replicas of the original filenames in folder B:


for f in A/*.png(.Non);
do
   touch B/"${f:t}"
done


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

how to batch copy and paste filenames

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.