They also have bash, which is the shell language we're using here, and all those little unix utilities (I looked them up and they appeared as the first result in Mac Manpages.)Īlso, make sure that the destination directory EXISTS, or it won't work.As a computer user, you always want to find yourself tools to help protect your device, clean up as well as ensure the safety of your document files, but finding a real tool Reputation and quality are extremely difficult. The reason why this will probably work on macs as well is because macs are unix-based. If the directory has some mp3's and some m4a's, then move all the mp3's in the directory to the specified destination directory. If the directory has no m4a's or no mp3's, skip it. If the directory we are looking at on the current iteration, skip it. Store some variables we need (number of mp3's, number of m4a's, number of files echo $DIR $mp3num $mp4num $filnum Just to make things safe so we can execute the script from any directory, as long as the script is in the same directory as all the directories of the music stuff. Parse the first argument as the destination directory and store it in $todir (a variable). Note that you can't do something as complicated like this without a script. Now navigate to that directory in the shell and type: bash (before you do this, read through the whole post)Ĭreate a text file in the parent directory of all those directories with the music in them and paste this in: (Specify the destination directory using the FIRST ARGUMENT) (i.e./thisscript.sh directoryname) (sorry for bad scripting practices, I'm not very good at shell scripting) (wrote it on theĪgain, this is assuming that Mac has bash, tr, grep, ls, rm, and wc (standard UNIX utilities, iirc) This script also assumes that you have ONLY mp3 and m4a files, and that some directories contain no mp3 and m4a files. (/bin/bash is the default shell executable). I'm assuming your mac has a /bin/bash for this, along with awk, tr, grep, ls, rm, and wc. This solution was tested on /bin/bash from a GNU/Linux system. (Cue comments correcting my dangerous use of find and while.) & mv -v -backup=numbered "$fin" $DEST_DIR/īefore running that version, I suggest replacing the line before done with the following line as a sort of dry run so you can get an idea of what will be moved: & echo "Moving $fin to $DEST_DIR/" # a number appended to its name to prevent overwritng of the existing files. # In the event of a file name clash in the destination dir, the incoming file has mp3 files starting in $SOURCE_DIRįind $SOURCE_DIR -type f -name "*.mp3" | while read fin # Create the destination directory for the moved MP3s, if it doesn't already exist. # Name of directory you want to move the MP3s to. # Name of directory under which you music is stored. Note that it's important to get the quoting of variables correct because music files often have lots of spaces in their names and bash interprets spaces as separating items in lists. The following bash script will do that, but it won't find duplicate MP3/M4A pairs of files that exist in different directories from each other. mp3 files and move the ones for which an equivalent. If I've understood this correctly then you just need to search for.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |