Need a script to create multiple folders
Need a script to create multiple folders
Author
Discussion

BitsandBobs

Original Poster:

24 posts

128 months

Friday 12th November 2021
quotequote all
Hi - I have to create 500, sequentially numbered folders, each containing a single common file (a PDF - other files will be added manually later)

Am on a Mac - and I need to do it this evening and I stacked trying to get the PDF signed off and I don't have time to mess about sorting the folders!

Any one got a script I could use ? Or a simple quick method?

Folder name would: '[xxxxxxxxxx] 001' etc - through to 500.

Thanks

mmm-five

12,386 posts

314 months

Friday 12th November 2021
quotequote all
Just create 1 folder with the common PDF in, then duplicate it 499 times.

Then user A Better Finder Rename to rename all the folders in the numbers scheme you wish.

theaxe

3,571 posts

252 months

Friday 12th November 2021
quotequote all
You can create the folders with the command (where myfolder is the first part of the folder name):

mkdir myfolder{001..500}

Then you can copy file 'a.pdf' into these folders with:

for f in */; do cp a.pdf $f; done



Edited by theaxe on Friday 12th November 19:44

ruggedscotty

5,997 posts

239 months

Friday 12th November 2021
quotequote all
It depends on how many folders you are after.

Ive always done this using a .bat file to create the folders.

and have used excel as a quick way of making the multiple folder names

this site may give you an idea.

https://www.thewindowsclub.com/how-to-create-multi...

thebraketester

15,811 posts

168 months

Friday 12th November 2021
quotequote all
mkdir -p 0{001..500}

That will give you folders 0001-0500'of you run it in terminal

BitsandBobs

Original Poster:

24 posts

128 months

Saturday 13th November 2021
quotequote all
Thanks smile All done