An interactive file renamer/mover inspired by git
npm install -g imv
- You give imv a glob pattern of files you want to move or rename.
imv './home/*.png'
- It opens the list in your favorite code editor (either by the
--editor
param or automatically via your git config).
./home/customer.png
./home/puppy.png
./home/cat.png
- You make the edits you want, with the tools you already use like multiple cursors and regex.
./home-page/user.png
./home-page/puppy.png
./home-page/cat.png
- Save the file and close it …sounds familiar to git commit/rebase?
- imv will make the changes, the file on each line becomes the new file location.
- imv deletes the old
/home
directory because the directory is now empty. - You're done!
Usage: imv [options] <glob>
imv -- interactive move files
Options:
-v, --version output the version number
-e, --editor <editor> use this editor to modify your file paths
-i, --ignore <glob> ignore files that match this glob pattern
-g, --gitignore ignore files that match patterns in .gitignore
-o, --overwrite overwrite existing files
-t, --trash send existing files to the trash bin
-k, --keep-empty keep empty affected folders after moving files
-h, --help output usage information
To keep things simple, there are a few limitations:
- It only moves files from the directory and any subdirectories where the
imv
command was made. - It cannot overwrite files that are also matched by the input glob pattern.
- It cannot swap two file paths.
You can install imv locally to develop on:
npm install
npm run dist
npm link
You can now use the imv
command from your terminal. npm start
will build in watch mode so you can make edits as you use the tool.
imv uses TypeScript for type safety, ESLint for linting, and Jest for testing.