Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Move files to (new) directory based on file name
for file in *; do dir=$(echo $file | cut -c $START-$END); mkdir -p $dir; mv "$file" "$dir"; done

This comment has been minimized.

Copy link
Owner Author

@daysm daysm commented Oct 15, 2020

cd into the directory with your files and execute

/path/to/ <start> <end>

<start> and <end> are the positions of the first and last character of the directory name as it is used in the file name. To use the character sequence from the 27th to the 43rd character in the file name as the new directory name, execute

/path/to/ 27 43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.