Post ASZaE9ZGwMS9Kt1FJ2 by dragnucs@social.touha.me
 (DIR) More posts by dragnucs@social.touha.me
 (DIR) Post #ASZZDHgFC1uGFiIlzk by kaia@brotka.st
       2023-02-11T14:31:03.355546Z
       
       2 likes, 3 repeats
       
       how do I mv/rename several files according to a pattern?the files are named e.g.'[SubsPlease] Some Anime Thing! - 06 (1080p) [658EC9948].mkv'I tried many variations of this and it does not do anything:$ rename -v 's/\[SubsPlease\] //g' *mkv$ rename --versionrename from util-linux 2.38.1thank you!
       
 (DIR) Post #ASZZYMHHINX4alfn2O by LunaDragofelis@fedi.criminallycute.fi
       2023-02-11T14:33:51.847852Z
       
       1 likes, 0 repeats
       
       @kaia you could always try writing an actual script for more complex stuff like thatusing shell or even python
       
 (DIR) Post #ASZZlVA1a0zNuHY0Nk by radix023@noagendasocial.com
       2023-02-11T14:37:15Z
       
       1 likes, 0 repeats
       
       @kaia it might be easier to pull the filenames into a text file and compose rename commands in vi. Personally I would use perl.
       
 (DIR) Post #ASZaE9ZGwMS9Kt1FJ2 by dragnucs@social.touha.me
       2023-02-11T14:37:43Z
       
       1 likes, 0 repeats
       
       @kaia You can do this with a GUI file manager like Nautilus or Thunar.https://www.linuxuprising.com/2019/04/how-to-enable-metadata-based-batch.htmlhttps://docs.xfce.org/xfce/thunar/bulk-renamer/start
       
 (DIR) Post #ASZaEUh8OKDgrLrJya by Johann150@genau.qwertqwefsday.eu
       2023-02-11T14:36:50.389Z
       
       1 likes, 0 repeats
       
       @kaia@brotka.st you can use a for loopfor file in *.mkv; donewfile=$(sed 's/\[SubsPlease\] //g' <<<"$file")mv "$file" "$newfile"done
       
 (DIR) Post #ASZaGFsESyrZTKtDuK by slesa@social.saarland
       2023-02-11T14:36:43Z
       
       1 likes, 0 repeats
       
       @kaia Something like here?https://stackoverflow.com/questions/6911301/rename-multiple-files-in-shell
       
 (DIR) Post #ASZaGtlu7vZJDIEjb6 by oblomov@sociale.network
       2023-02-11T14:42:31Z
       
       1 likes, 0 repeats
       
       @kaia As written it works with the perl-based file-rename (to which rename maps in some distro). Pure shell version:for file in *.mkv ; do mv "${file}" "${file#\[SubsPlease\] }" ; donewhich works only to remove the prefix. If you have to change something in the middle of the file it's a bit more complex.
       
 (DIR) Post #ASZaSdE3TD3bN7zyuO by wakarimasen@shitposter.club
       2023-02-11T14:45:02.963968Z
       
       1 likes, 0 repeats
       
       @kaia I think the syntax you’re using is perl rename syntax (which is a different tool than the util-linux rename). For what it’s worth, the util-linux one never worked properly for me either.
       
 (DIR) Post #ASZafdniduUov8sqOm by tai@shitposter.club
       2023-02-11T14:47:24.181151Z
       
       0 likes, 0 repeats
       
       @kaia since you already have it, rename needs the pattern and replacement separately so in this case you could just do rename '\[SubsPlease\]' '' *.mkv
       
 (DIR) Post #ASZbWBHRPcWVoUq4PY by rohrkrepierer@merovingian.club
       2023-02-11T14:55:15Z
       
       1 likes, 0 repeats
       
       @kaia So I take it you want to cut [SubsPlease]' from the titles? Try `$ rename -v \[SubsPlease\] '' *.mkv`
       
 (DIR) Post #ASZcJrjGNSrPehXmO8 by mvonkarnstein@minidisc.tokyo
       2023-02-11T14:59:41.134Z
       
       1 likes, 0 repeats
       
       @kaia@brotka.st rename does not use the substitution command and take three arguments: text to be replaced, replacement and files. So it would look like:$ rename -v "[SubsPlease] " "" *.mkv(second argument is an empty string)
       
 (DIR) Post #ASa5cUXZiHsduVJJlw by scathach@stereophonic.space
       2023-02-11T20:33:42.447957Z
       
       1 likes, 0 repeats
       
       @kaia For renaming multiple files I usually use nnn's bulk-rename function https://github.com/jarun/nnn