I am trying to run this as a script https://hastebin.com/xemitireri.bash ,
#!/bin/bash # https://stackoverflow.com/questions/1806868/linux-replacing-spaces-in-the-file-names find . -type d | while read N do ( cd "$N" if test "$?" = "0" then for file in *; do mv "$file" ${file// /_}; done fi ) done
I want to run this recursively in one folder, in which there are several folders, each of which has several files. Both folder names and file names have spaces in them (for example, to run in the "Test" folder, which contains a "Good album", which contains "Disk 1", "Disk 2", etc. Each folder of the disk has "Song 1.txt", "Song 2.txt", "Song 3.txt, etc.). This DID renames the folders, but not the files inside the folders. I get the error bash: cd: ./ Disk 02: no such a file or directory bash: cd: ./ Disk 01: there is no such file or directory bash: cd: ./ Disk 03: there is no such file or directory
user311009 Jul 13 '17 at 9:51 on 2017-07-13 21:51
source share