fscode can generate a "code text" file containing information about the filenames you pass in. You can then perform file operations directly through your code editor.
fscode-demo.mp4
pip install PyFSCode
# Linux/MacOS
find ./photos -name "*.jpg" | fscode --editor='code -w' *.txt
# Windows
ls -Name -Force -Recurse | fscode- ๐ป Editor as UI โ Use the code editing capabilities of VS Code/Jetbrains to operate files;
- ๐ง Smart Dependency Handling โ Automatically resolves swap, cycle, and move conflicts;
- ๐ก๏ธ Safe and Controllable โ Does not modify files directly, only generates a reviewable file operation script;
- ๐งฐ Full Features Support โ Supports creation, copying, moving, deleting, renaming and Symlink.
- ๐จ Custom Commands - For example, you can replace
touchwithai-generateto create files with content. - ๐ท๏ธ Custom Command Prefix - For example, you can use
sudoas a prefix for the output script.
pip install PyFSCode
# Or using uv
uv tool install PyFSCode$VISUAL or $EDITOR environment variable points to VS Code, please use --editor='code -w' to wait for the window to close before continuing.
find ./photos -name "*.jpg" | fscodefscode *.jpg *.txtfind ./photos -name "*.jpg" | fscode *.jpg *.txtfscode --editor='code -w' --create='new' --remove='del' --move='mov' --exchange='mv --exchange -iT' **The editor will open a file similar to this:
# <ID> <Path> [args...]
1 photos/vacation.jpg
2 photos/birthday.jpg
3 project/notes.txt
4 "photos/old picture.jpg"You just need to modify it:
# File Operation Plan
# ... (comments omitted) ...
#
# My Modifications
# 1. Rename (Edit the path)
1 photos/Paris_Vacation_2025.jpg
# 2. Move (Edit the path)
3 archive/old_notes.txt
# 3. Copy (Duplicate the line, use the same ID 2)
2 photos/birthday.jpg
2 photos/backup_birthday.jpg
# 4. Delete (Delete or comment out the line with ID 4)
# 4 "photos/old picture.jpg"
# 5. Create (Add a new line, ID is 0, quotes are needed due to spaces)
0 'new_project/new note.txt'
# 6. Create a symbolic link
0 note.txt 'new_project/new note.txt'After saving and closing the editor, FSCode will generate a script:
#!/bin/sh
cp photos/birthday.jpg photos/backup_birthday.jpg
mv photos/vacation.jpg photos/Paris_Vacation_2025.jpg
mv project/notes.txt archive/old_notes.txt
rm 'photos/old picture.jpg'
touch 'new_project/new note.jpg'
ln -snT 'new_project/new note.txt' note.txtAfter reviewing it for correctness, execute it:
source ./file_ops.shโ All changes can be safely reviewed before execution.
NAME
fscode - Main execution flow.
SYNOPSIS
fscode <flags> [PATHS]...
DESCRIPTION
Main execution flow.
POSITIONAL ARGUMENTS
PATHS
Type: str
File paths to process. Can be provided as arguments or via stdin.
FLAGS
--editor=EDITOR
Type: str
Default: 'code -w'
The editor command to use (e.g., "msedit", "code -w"). Defaults to $VISUAL, $EDITOR, or 'code -w'.
-o, --output_script=OUTPUT_SCRIPT
Default: 'file_ops.sh'
Path to write the generated shell script.
--edit_suffix=EDIT_SUFFIX
Default: '.sh'
Suffix for the temporary editing file. Defaults to '.sh'.
-n, --null=NULL
Default: False
Whether to use null-separated input.
--copy=COPY
Type: str
Default: 'cp'
The command to use for copy operations.
--move=MOVE
Type: str
Default: 'move -Confirm'
The command to use for move operations.
--exchange=EXCHANGE
Type: str
Default: ''
The command to use for atomically swap filenames. Currently, only higher versions of Linux support the `mv --exchange -iT` command.
-r, --remove=REMOVE
Type: str
Default: 'del -Confirm -Recurse'
The command to use for remove operations.
--create=CREATE
Type: str
Default: 'ni'
The command to use for create operations.
--create_args=CREATE_ARGS
Type: str
Default: 'ni -Confirm...
The create command with extra arguments (e.g., for symlinks).
--move_tmp_filename=MOVE_TMP_FILENAME
Type: Optional[str | None]
Default: None
Path for the temporary filename used during cycle move operations.
-i, --inode=INODE
Default: False
Whether to display inode and hard link count. When adding a new row, the Inode and Links columns must be set to None.
--cmd_prefix=CMD_PREFIX
Default: ''
An optional command prefix to prepend to all commands.
alias -s fscode "fscode --editor='code -w' --create='new' --remove='del' --move='mov' --exchange='mv --exchange -iT'"- To use hard links, you can use
--inodeto display hard link information. Use--cp='ln -snT'to replace the cp operation. - To use soft links, you can modify the
[args...]column and set the ID to 0; fscode will then automatically use create_args to create them. If you need to force-create and overwrite, you must manually change--create_args='ln -snTf'. Currently, only the "create" function supports custom arguments. If the project gets 1000 stars โญ, I will consider adding custom arguments for all operations. - To use
sudo, you can set--cmd_prefix=sudo, which will add this prefix to all commands.
| Tool | โ Count | Cross-editor | Interactive | Output Script | Custom Commands | Move | Swap/Cycle | Copy | Delete | Create | Symlink | Hardlink |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| edir | 5 | โ | โ | โ | โ | โ | โ | โ | โ | โ | โ | โ |
| renameutils | 5 | โ | โ | โ | โ | โ | โ | โ | โ | โ | โ | โ |
| pipe-rename | 3 | โ | โ | โ | โ | โ | โ | โ | โ | โ | โ | โ |
| massren | 4 | โ | โ | โ | โ | โ | โ | โ | โ | โ | โ | โ |
| dired | 9 | โ | โ | โ | โ | โ | โ | โ | โ | โ | โ | โ |
| acme | 8 | โ | โ | โ | โ | โ | โ | โ | โ | โ | โ 1 | โ 1 |
| up | 3 | โ | โ | โ | โ | โ | โ | โ | โ | โ | โ | โ |
| fscode | 10 | โ | โ | โ | โ | โ | โ | โ | โ | โ | โ | โ 2 |
- Due to the nature of Plan 9, the system doesn't use "link" but rather "bind".
- Just set
--copy='ln -nTf'and--inode, and you can handle hard links just like regular copying.
This project is open-sourced under the MIT License.
Like this project? Please give it a โญ๏ธ Star. Your support helps more people discover it.