sluggo45 47 Posted September 5, 2018 Share Posted September 5, 2018 I have a script question that should be simple but I'm being stupid:I've created/modded a post-processing script for Emby that converts/renames media, cuts commercials, etc. based on several excellent suggestions elsewhere in the forum. It runs fine except when it runs in to certain titles.Example problem (test.sh script I did for troubleshooting): #!/bin/csh set path = ($path /usr/local/bin) set w1 = `jot -r 1 2 15` set filename = `printf "%s " $1:t:r:r` set grab = `printf "%s " $1:h` set a = `echo "$filename".ts` set b = `echo "$grab/$filename"_cut.ts` set c = `echo "$grab/$filename".mp4` set d = `echo "$grab/$filename".srt` echo "$filename" If the external input ($1) is, say, this: "/media/recording/Family Guy (1999)/Season 8/Family Guy S08E20 The Splendid Source.ts" It works fine. The script grabs the correct filename/path, then I assign different variables so the rest of my script can work correctly (i.e. _cut.ts is the new name after I run Comskip/comcut, the others after I extract subtitles and convert to .mp4, and so on).However if I have a show like this: "/media/recording/House Hunters International (2006)/Season 117/House Hunters International S117E01 House Fishing in St. Croix.ts" Everything after the . in "St. Croix.ts" is truncated "/media/recording/House Hunters International (2006)/Season 117/House Hunters International S117E01 House Fishing in St.ts" However if I echo "$1" I get the correct showname back - so the variable from Emby is being passed in correctly, my script/printf is screwing it up. In my test script, the above name echos this for $filename House Hunters International S117E01 House Fishing in St Obviously I'm not escaping correctly but I can't figure it out and my tiny brain is tired.How can I sanitize $1 correctly? This: set filename = `printf "%s " $1:t:r:r` set grab = `printf "%s " $1:h` Is so it's easier to rename the files without an extra .ts on the end (i.e. "filename.ts.mp4") Link to comment Share on other sites More sharing options...
sluggo45 47 Posted September 6, 2018 Author Share Posted September 6, 2018 Figured it out while the forums were having problems Didn't know about the basename utility: set filename = `basename "$1" .ts` now to figure out how to clean up the files afterwards properly. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now