File names changed to folders??

Posted:
in Mac Software edited January 2014
Does anyone know of an application or utility that will:



- copy a list of file names,



- then output that list of file names to folders with corresponding names in a new window as to not overwrite the files?

Comments

  • Reply 1 of 1
    MarvinMarvin Posts: 15,324moderator
    You wouldn't get an app to do it. You might get an Automator workflow but a script is easier. Try the following Python script:



    Code:




    import os

    import sys



    if(len(sys.argv)<3):

    >print "specify input and output directory"

    >sys.exit()



    dirin = sys.argv[1]

    dirout = sys.argv[2]



    for root, dirs, files in os.walk(dirin):

    >for f in files:

    >>if(f.startswith('.')): continue

    >>newfolder = dirout+"/"+f

    >>print "making "+newfolder

    >>os.system("mkdir '%s'" %(newfolder))











    Paste that into a plain text document, change the > to tabs and save as filestofolders.py. Then open a terminal and type:



    python <drag filestofolder.py here> <drag folder of files here> <drag output folder here>



    Just drag the files and folders onto the terminal window in that order and hit return. It will tell you what it's doing. The mkdir command by default checks if a file or folder exists and won't overwrite.
Sign In or Register to comment.