![]() New directories can be created using the mkdir command. The -l option is used to give more information, including: permissions owner, and owning group file size and date last modified in addition to the filename. Typing ls on it's own will list all the files and directories contained within the current directory. The ls command can be used to list the contents of a directory. The $OLDPWD variable is useful if you want to move back to the directory you were at previously.Ĭd $OLDPWD Listing the Contents of a Directory (ls) To view the current working directory you can view the $PWD variable, and to view the previous directory there is the variable $OLDPWD. There are also two shell variables that are normally set. The pwd (print working directory) command will return the name of your current directory. When moving around the directory structure it's easy to forget where you are. To change directory use cd followed by either the absolute or relative directory. You can move around the directories by using the cd (change directory command). This is normally /home/username (for username stewart that will be /home/stewart). When first logging onto a UNIX system you will normally be in your "home" directory. These are command-line programs that can often be used together by using pipelines or redirects (see the Command Basics Reference Guide). This shouldn't happen.The guide lists some of the useful commands. If || thenĮcho mv -v "'$THISLINE'" "'$directory/$filename_clean'" > /tmp/filenames_toreview_$$.txtĮcho "File or dir disappeared. If (test "$filename" != "$filename_clean")Įcho "missmatch: '$filename' != '$filename_clean'" and reverse list it, to prevent "file disappeared" (parent dirs are changed last)įind "$1" -depth | sort | tac >/tmp/filenames$$.txtįOUNDNUM=$(cat /tmp/filenames$$.txt | wc | awk '')Įcho "# found $FOUNDNUM filenames or dirnames to check."Įcho "# found $FOUNDNUM filenames or dirnames to check." > /tmp/filenames_toreview_$$.txtįor THISLINE in $(cat /tmp/filenames$$.txt) do # this function doesn't change files on its own Note: there may occur "already exists" problems when doing the actual rename. more edge cases for samba (trailing/leading spaces).going via a two-stage temp file (is faster on my machine).don't touch files/dirs, create batch list instead (to review).Same steps as above but I added one more sed command to remove a period at the end of the directory If true, it renames the file with the mv command, then outputs the changes it made with the echo command.Checks to see if the file name needs changing.Removes possible double or triple periods. ![]() Removes all other characters except for letters A-Za-z, numbers 0-9, periods ".", and dash's "-".Only process *.srt files( * could be used in place of *.srt to process every file). ![]() I use this one-liner to remove invalid characters in subtitle files: for f in *.srt do nf=$(echo "$f" |sed -e 's//./g s/\.\.\././g s/\.\././g') test "$f" != "$nf" & mv "$f" "$nf" & echo "$nf" done
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |