Skip to main content

Filename Studio Code

Project description

๐Ÿงฉ FSCode (File Studio Code) โ€” Operate files like writing code

English ็ฎ€ไฝ“ไธญๆ–‡

PyPI License: MIT GitHub Stars

๐Ÿš€ What Can It Do?

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.

โšก๏ธ Video Demo (Very Important!!!)

Video Demo

๐Ÿ Quick Start

pip install PyFSCode
find ./photos -name "*.jpg" | fscode --editor='code -w' *.txt

โœจ Core Features

  • ๐Ÿ’ป 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 touch with ai-generate to create files with content.
  • ๐Ÿท๏ธ Custom Command Prefix - For example, you can use sudo as a prefix for the output script.

๐Ÿ“ฆ Installation

pip install PyFSCode
# Or using uv
uv tool install PyFSCode

๐Ÿง‘โ€๐Ÿ’ป Usage Example

๐Ÿ’ป Step 1: Input Files from Command Line

โš ๏ธ [NOTE]: If your $VISUAL or $EDITOR environment variable points to VS Code, please use --editor='code -w' to wait for the window to close before continuing.

Method 1: Input from Pipe

find ./photos -name "*.jpg" | fscode

Method 2: Pass as Arguments

fscode *.jpg *.txt

Method 3: Pipe + Arguments

find ./photos -name "*.jpg" | fscode *.jpg *.txt

Method 4: Use Custom Commands (Advanced Users)

fscode --is_exchange --inode --editor='code -w' --create='new' --remove='del' --move='mov' **

๐Ÿ“„ Step 2: Modify Filenames in the Editor

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'

โšก Step 3: Execute

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.txt

After reviewing it for correctness, execute it:

source ./file_ops.sh

โœ… All changes can be safely reviewed before execution.

๐Ÿ“„ Help Documentation

INFO: Showing help with the command 'fscode -- --help'.

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'
        The editor command to use (e.g., "msedit", "code -w"). Defaults to $VISUAL, $EDITOR, or 'code -w'.
    -o, --output_script=OUTPUT_SCRIPT
        Type: str | pathlib._local.Path
        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
        Default: 'cp'
        The command to use for copy operations.
    --move=MOVE
        Default: 'mv'
        The command to use for move operations.
    --exchange=EXCHANGE
        Default: 'mv --exchange'
        The command to atomically swap filenames. If you modify to a custom command, is_exchange is automatically enabled.
    -r, --remove=REMOVE
        Default: 'rm'
        The command to use for remove operations.
    --create=CREATE
        Default: 'touch'
        The command to use for create operations.
    --create_args=CREATE_ARGS
        Default: 'ln -snT'
        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.
    --is_exchange=IS_EXCHANGE
        Default: False
        Use swap for circular moves and avoid using temporary files. Currently only higher versions of linux are supported.
    --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
        Type: Optional[str | None]
        Default: None
        An optional command prefix to prepend to all commands.

๐ŸŒˆ Other Recommended Tools

๐ŸŸ fish alias example

alias -s fscode "fscode --is_exchange --editor='code -w' --create='new' --remove='del' --move='mov'"

๐Ÿชถ Tips

  • To use hard links, you can use --inode to 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.

๐Ÿ”— Feature Comparison

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
Note
  1. Due to the nature of Plan 9, the system doesn't use "link" but rather "bind".
  2. Just set --copy='ln -nTf' and --inode, and you can handle hard links just like regular copying.

Appendix

๐Ÿ“„ License

This project is open-sourced under the MIT License.

๐Ÿชถ Tips

Like this project? Please give it a โญ๏ธ Star. Your support helps more people discover it.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyfscode-1.0.1.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyfscode-1.0.1-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file pyfscode-1.0.1.tar.gz.

File metadata

  • Download URL: pyfscode-1.0.1.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pyfscode-1.0.1.tar.gz
Algorithm Hash digest
SHA256 40ce892f47c9705b9ef80ec0503de6833f993eef5db5a6a4b25bf25ba4b59883
MD5 6c15eaf3dab2c33dedf0a9b2e3bf37ce
BLAKE2b-256 e5dd32c79b1ff863c0ba7f54dd15ae3aff8b39ab74353445baabba273eebe616

See more details on using hashes here.

File details

Details for the file pyfscode-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pyfscode-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pyfscode-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2480ca13ee9f81a34b0e24075f690dcf074f9d6b3765a8f3b26228364c5fc538
MD5 0ad805619e42a7b6cf4c18ee3b7219b4
BLAKE2b-256 e017fb4b2d54a1fddc64ccabded740dabb94a8a303cbc4633fa47cdfc00378ac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page