3

I downloaded a bunch of youtube videos and transcripts, and I am trying to rename them using the 11-character youtube ID that is part of the file title. I created a text file where I have on each line the old title, the new title and separated by the character ">"

I am using the following command:

parallel -j 4 --colsep '>' mv "{1}" folder/{2} :::: rename.txt

This only works for 90% of the files. 10% of the files are left behind with an error. I am attaching below some file names that don't work. I am suspecting some characters are mot mv friendly, but I am stuck.

'Design at Large -  Scaling the Studio and the Lab to the Globe' _ Scott Klemmer _ TEDxUCSD-HcMsp0wVH5Q.en.vtt
'Do yourself a favour  - DONATE BLOOD' _ Meenakshi Lekhi _ TEDxDITE _ Mrs. Meenakshi Lekhi _ TEDxDITE-Sq3x7HYM3UQ.en.vtt
'I am cool with myself'  - Serah. G. at TEDxInhaU-SUZ5hCqws6U.en.vtt
'Play Dead' (Björk),  _ Corisco & Costellas Madera de mar _ TEDxCadizUniversity-OpbzqHN7FOU.en.vtt
'Species on the Move'  _ Chad Jones _ TEDxConnecticutCollege-sqTZ5MXxm4c.en.vtt
'The Art of Being Wrong'  _ Kim Schlesinger _ TEDxWartburgCollege-Kzv-lMv4qRY.en.vtt
'There's a better way to do it.  Find it' _ John Keegan _ TEDxNJIT-Vrw5brX1Wfo.en.vtt
(Please), Don’t let us go extinct  _ Samantha Matheijsen _ TEDxAvansUniversity-QAPId_JNcjw.en.vtt
(Pre)Human 3.0  _ Luc Deleuze _ TEDxUNamur-E7N5__flfkY.en.vtt
12x16 -  The Messy Process of Unlearning _ Dominic Inouye _ TEDxUWMilwaukee-Ql7y19kBojY.en.vtt
2017's Mind-Blowing Drone Innovations  _ Donna Chiu _ TEDxHKUST-T8jg5YS8hZ0.en.vtt
21st Century Education -  The Science of Understanding _ Tom Koch _ TEDxGettysburgCollege-TAOKCxl71g0.en.vtt
3 Most Important Ingredients For making  Perfect Success Recipe _ Bhupendra Rathore _ TEDxBalajiITS-_k65z2WEUqA.en.vtt
3 counter-intuitive ways to achieve anything you want  _ David LAROCHE _ TEDxKedgeBS-aad7N-qJE40.en.vtt
3 reasons why we should share our stories with the world  _ Praveen Wadalkar _ TEDxKhulnaUniversity-YtEa0mirjHo.en.vtt
320 Cakes - The Existential Escapade  _ Natalie Rowland _ TEDxWilliam&Mary-1oEpR3UPLz8.en.vtt
5 Ways to Run a Great Blog  _ Kimberly D'Souza & Denver Britto _ TEDxBITSPilaniDubai-UogiOStY-Ps.en.vtt
63 Days of Superstition  _ Tanushri Sundar _ TEDxBrownU-Lgmu84-Pxv4.en.vtt
8 + 8 + 8  - Time Management  _ Gyanvatsal Swami _ TEDxMSUniversityofBaroda-MmlEQwdqlfo.en.vtt
A  PATHWAY TO HEALTHY SOCIETIES _ Rameshwar Nath Kaul Bamezai _ TEDxJECRC-LoYFgaF0PXM.en.vtt

Would you mind helping me? Thanks!

Léa Gris
  • 17,497
  • 4
  • 32
  • 41
user1029296
  • 609
  • 8
  • 17

2 Answers2

3
  1. Always mark the end of options on commands working on paths or filenames with -- to prevent file-names or pattern globbing from being interpreted as options.
  2. Always use double-quotes for strings containing variables to prevent the variable content to be split on space or having special characters interpreted.
parallel -j 4 --colsep '>' mv -- {1} folder/{2} :::: rename.txt
Léa Gris
  • 17,497
  • 4
  • 32
  • 41
  • GNU Parallel quotes its replacement strings (they are not shell variables), so the problem here was most likely the missing --. – Ole Tange Jul 12 '19 at 09:40
-1

The issue you're experiencing is special characters being interpreted by the shell (or by the parallels tool).

To move these files, you will need to escape (add a backslash: ) to certain parts of the file. Here's a few examples:

mv \'The\ Art\ of\ Being\ Wrong\'\ \ _\ Kim\ Schlesinger\ _\ TEDxWartburgCollege-Kzv-lMv4qRY.en.vtt folder/

mv Play\ Dead\'\ \(Björk\)\,\ \ _\ Corisco\ \&\ Costellas\ Madera\ de\ mar\ _\ TEDxCadizUniversity-OpbzqHN7FOU.en.vtt folder/

mv 320\ Cakes\ -\ The\ Existential\ Escapade\ \ _\ Natalie\ Rowland\ _\ TEDxWilliam\&Mary-1oEpR3UPLz8.en.vtt folder/

etc.

See Escaping Filenames and Explaining what needs to be escaped for more information

somelement
  • 126
  • 7
  • GNU Parallel quotes replacement strings in a way that is equivalent to the \-quoting shown here. So this is not the problem. – Ole Tange Jul 12 '19 at 09:42