0

I got 2 main folders Peliculas and Series, as you may guess Peliculas has movies on it (some of them on their own folder, the ones that have more than 1 file) and the folder Series has tv shows.

What I need is a command line or script so I can zip each subtitle ( .srt file) and move it to a folder on the home like ~/MovieSubtitles/We Own The Night.zip and ~/SeriesSubtitles/Masters of Sex S01E11 - Phallic Victories.zip

The folder structure is something like this:

on Movies:

Peliculas
|-10 Things I Hate About You (1999) BRRip 1080p
|-10,000 B.C. (2008) BRRip 1080p
|-10th & Wolf (2006) DvDRip
etc...

on Tv Shows:

Series
|-Anger Management
| |-Anger Management 1x
| |-Anger Management 2x
|-Breaking Bad
| |-Breaking Bad 1x
| |-Breaking Bad 2x
| |-Breaking Bad 3x
etc..

And. Well. I have a lot. Really a lot so I need some script. Can't do it manually and want to keep a backup of each subtitle on the folders mentiones before, so I could upload them and make them available when needed like in the yifi subtitles website

So what I need is to zip each srt on the folder Peliculas recursively and Series also recursively (but in this case on 2 leveles, as each season is also on a subfolder inside the series' folder) , keeping the name of the srt file and place the zip on a folder on my home.

Any ideas?

/*************
*   Edited
*************/

Google....ing.?... i came with this solution :

:~$ find /media/peliculas/ -name *.srt -exec zip '{}'.zip ~/subtitulos/peliculas/

(tryed -iname 'srt', -iname '.srt', -name '*srt' and others based on Bendrami's idead and it's all the same)

*find /media/peliculas -name .srt prints out the whole srt files (subtitles) list on the peliculas folder... but as soon as i use -exec

i got the error => find: missing argument to '-exec'

so plz help....

for some extra points.. :P may be best to name the zipfile as the folder containing the srt file as it hast the full name of the movie, the year and the quality.

  • i cannot fully understand your need...Would you like to zip everything under Peliculas ? everything under Anger Management and under Breaking Bad ? – user2196728 Dec 22 '13 at 19:28
  • Props for including "Masters of Sex: Phallic Victories", that under-appreciated work of genius... – Bandrami Dec 23 '13 at 5:23
  • I want to zip each subtitle into his own zipfile, not altering any of the movies/series files, just zipping all the subtitles (each sub into his own zipfile) and saving the zip files into a folder at home.. ~/Subtitulos/Series and ~/Subtitulos/Peliculas (the first path to save the series zipped subtitles, and the second for zipped movie subs) – Ph1L82 Dec 24 '13 at 20:10
0

Put this script in your home directory:

#!/bin/sh
x=`basename $1`
zip $2/${x}.zip $2/${x}
rm $2/${x}

Then run

find /path/to/subtitles -iname '*srt' -exec ~/yourscript.sh {} /path/to/zip/directory

If you have any collisions it will prompt you what to do.

  • could you plz explain what this do? I'm trying to addapt what i think you did there to my needs... as far as now all I get is a list of the srt files.. that's great :) and also piping it i can zip them all into where i want.. but all in the same zip and i need to zip each SRT individualy into a subtitles folder in my home, 1 folder for series and other folder for movies, not erasing any files the hard part is zipping each srt individualy and setting the zip filename to be the same of the srt... as far as now using exec i only get: ` find: missing argument to -exec' – Ph1L82 Dec 24 '13 at 21:05
0

I got it to work this way with 2 lines..

1)

 find  -name *.srt -exec  zip -D9 '{}'.zip '{}' \;

what this does is find any SRT (subtitle file) inside the folder u execute it.. in my case.... /media/peliculas (wich holds all my movies) and best-compress it without the directory entries (It doesn't add trash but it adds the movie folder... worked for me at the end.. would like to polish it ) each srt on his own zip file called as the srt file... so the subtitle from Dr. Strangelove or How I Learned to Stop Worrying and Love the Bomb it's saved on a zipfile called Dr. Strangelove or How I Learned to Stop Worrying and Love the Bomb.srt.zip

2)

find -name '*.zip' -exec mv '{}' ~/subtitulos/peliculas/ \;

and this.. the last part... well it moves all the zip files to a folder in my home where i'll hold the zipped subs.. and upload them to subtitles websites...

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.