Skip to main content
added 8 characters in body
Source Link
klanomath
  • 67k
  • 10
  • 135
  • 204

I have a folder with thousands of files in this format

  • filenameA - 1.ext
  • filenameA - 2.ext
  • filenameB - 1.ext

filenameA - 1.ext filenameA - 2.ext filenameB - 1.ext andand sometimes filenameB - 02.ext

  • filenameB - 02.ext

I need a script that will read the files and create a single folder with each distinct filename before the " - #.ext" and then add all files with that same name into the folder.

From the example above I would have two folders 1)filenameA filenameA 2)filenameB filenameB - each with two files in them. The actual data has thousands of files and each group can have 1 to 50ish files, with sequential numbers added to the end.

Thank you!

I have a folder with thousands of files in this format

filenameA - 1.ext filenameA - 2.ext filenameB - 1.ext and sometimes filenameB - 02.ext

I need a script that will read the files and create a single folder with each distinct filename before the " - #.ext" and then add all files with that same name into the folder.

From the example above I would have two folders 1)filenameA 2)filenameB - each with two files in them. The actual data has thousands of files and each group can have 1 to 50ish files, with sequential numbers added to the end.

Thank you!

I have a folder with thousands of files in this format

  • filenameA - 1.ext
  • filenameA - 2.ext
  • filenameB - 1.ext

and sometimes

  • filenameB - 02.ext

I need a script that will read the files and create a single folder with each distinct filename before the " - #.ext" and then add all files with that same name into the folder.

From the example above I would have two folders 1) filenameA 2) filenameB - each with two files in them. The actual data has thousands of files and each group can have 1 to 50ish files, with sequential numbers added to the end.

Source Link

Terminal script to create folders and copy files based on part of filename

I have a folder with thousands of files in this format

filenameA - 1.ext filenameA - 2.ext filenameB - 1.ext and sometimes filenameB - 02.ext

I need a script that will read the files and create a single folder with each distinct filename before the " - #.ext" and then add all files with that same name into the folder.

From the example above I would have two folders 1)filenameA 2)filenameB - each with two files in them. The actual data has thousands of files and each group can have 1 to 50ish files, with sequential numbers added to the end.

Thank you!