So, the easiest way is to use apostrophes, quotation marks, or. name "*.$FROM" | cut -d "/" -f 2 | sort)Įxport song=$(echo $FILES | tail -n $CNT | head -n 1)Įxport song_title=$(echo $song | cut -d. It becomes challenging, especially to access a path that has a folder with space in its name. I was only interested in getting the complete file name, so I found it necessary to remove the extension before converting it using the TO variable. It also does some additional cutting in the loop to remove the extension. The script I used includes FROM and TO parameters for specifying the audio formats. Since I was converting audio, I wanted to use the original filenames (including their spaces) for the new, converted audio files. Use a combination of tail and head to select the files line by line (like a SQL cursor).Use the count to loop through the files.This solution worked for me on OSX, using zsh: The file names had spaces, which caused issues for the converted file names. bashrc file for changing directory when pasting directory names containing spaces on to the command. I had a similar problem in a script I used to convert audio files. File contents: cd /My Code Now granted, this isnt a long pathname, but my actual pathname is five directories deep and four of those directories have spaces in the path. Tar: Exiting with failure status due to previous errors type f -iname '*.*'` do ls $REPLY doneīut I get the following error bash: read: `./F1/F1-': not a valid identifierĪs suggested in the answers below I updated the scripts #!/bin/bashįor FILE in "$(find. I tried using read with a while loop, while read `find. Im trying to read a filename with consecutive spaces on the filename ex: filenam The. F1/F1- and then the next part 160413.csv. Hello, Im using cygwin app which we use the bash shell for scripting. ![]() Stack Exchange Network Stack Exchange network consists of 182 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. type f -iname '*.*'īut the FILE variable only stores first part of the path. I need the file names to remain intact /bin/bash for file in find. The find command gives me the following output find. Beware that in this case the path itself shouldnt contain a string test. It finds the files in the current working directory recursively, echoes the original file name ( p) and then a modified name ( s/test/spec/) and feeds it all to mv in pairs ( xargs -n2 ). I have a script which searches all files in multiple subfolders and archives to tar. name 'test.rb' sed -e 'p s/test/spec/' xargs -n2 mv.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |