wallstreetiop.blogg.se

Shell script scan master file and delete it
Shell script scan master file and delete it







shell script scan master file and delete it

In the above for loop, mv is used to move each file ( "$file") to the respective episode directory ( "$(echo $file | sed -E 's/.*S+(E+).*/\1/')"). mkv extension: for file in *.mkv do mv "$file" "$(echo $file | sed -E 's/.*S+(E+).*/\1/')" done

shell script scan master file and delete it

You can use this from the directory where you have your files and empty directories, supposing that your files have an. Would anyone have a suggested plan of approach or be able to point me towards a resource I could refer to for help? Unfortunately I am not sure the correct approach in doing this with a script that I can run on the command line. My thought is to maybe iterate through all the existing E# folders, look for a file that contains that E# sequence, and then move that file into the folder. I am an experienced programmer, but have not worked with shell scripts yet. What is constant though is that S#E# will always appear in the filename and I only need to use the E# to identify the correct file and move it into the folder that already exists and exactly matches the E# from the file. The issue is that the files are not always in the same format, and will obviously have different names depending on the show. I have to repeat the steps for as many episodes as I have in the original directory, and given the fact I am essentially repeating the same steps and just iterating the episode number, it seems like a perfect use of a for loop in a script. Then I type the correct folder to get to mv tv.1.mkv E01/Īnd then hit Enter to complete the command. Then type 1 and Tab again to get to mv tv.1.mkv Essentially I am typing: mv tĪnd then hitting the Tab key to autocomplete out to mv tv.01E0 I have been moving the files manually at this point with the help of Tab autocompletion at the command line. 2.mkv, 3.mkv, ect.Īnd empty directories in the format E01, E02, E03, ect.

SHELL SCRIPT SCAN MASTER FILE AND DELETE IT TV

I want to automate moving TV show episode files into individual directories for each episode.Įssentially, in the folder I want to run the script in, I have a list of files.









Shell script scan master file and delete it