Put Your Command Line On Steroids With Swiss File Knife [Windows]
Sometimes, the fastest way to accomplish a task such as sorting files or editing text documents is to use quick command line tools.
If you’ve followed my recent scripting articles, then you know that I really like command line programming. I use Windows Scripting , but lots of readers still use the old batch jobs, which still work well.
However, there is a really cool tool called Swiss File Knife (sfk), which extends the sort of scripting set we’ve all become accustomed to.
The tool includes the usual command file functions that you may be used to, like mkdir, copy or list, but it extends your cmd powers with other amazing features like easily manipulating files, analyzing folders, and even higher level functions not usually associated with command line commands.
Setting Up Swiss File Knife
Setting up sfk on your computer is really easy. First, download sfk and place the executable somewhere on your hard drive, and then edit the PATH in the environment variables so that the path where that file is located is included.
Reboot your computer, and then you’re ready to get started. There are loads of really cool commands that you can kick off with sfk, but I wanted to touch on the ones that I liked the most.
One of the useful commands that come in handy when you’re trying to figure out what folders or directories are hogging all of your computer hard drive space is the treesize command.
“sfk treesize [directory]” will run down through all subdirectories, showing you how many files each directory has and the total memory consumption.
At the bottom of the results, you’ll find the total statistics for the folder you launched the command against. You’ll see a total count of files, directories and memory usage.
Another useful command for when you want to run a script that doesn’t allow for directories or files with spaces, is the sfk deblank command.
The command is used to target a file, directory, or all files within a directory. To remove spaces from all file names inside a directory, just type “sfk deblank [directory name]”.
This will go through the entire directory and rename any file with a space in it, replacing spaces with the underscore character.
Getting into some of the more advanced features of sfk is the snapto command, which can take multiple text files and collect the contents into a single file. This is really useful for collecting a collection of log files all into one file.
The command for this is “sfk snapto=filename.txt”. Filename.txt is the name of the output file where you want all of the combined text contents to output to.
One of my favorite commands in sfk is the httpserv command. By simply navigating to a particular folder and typing “sfk httpserv”, you can instantly launch a simple web server, with that directory as the root web directory.
The command uses your computers current network IP address as the web host IP, so any other computer on the network can open up that directory by opening up a web browser and typing that IP into the address. This is a really cool way to instantly share out an HTML page you may be working on, or if you want to quickly show someone the contents of a folder over the network.
While you might be tempted to use this to share out files, like pictures or movie files, it’s actually faster to launch a quick FTP server using my other favorite sfk command, ftpserv.
When you type “sfk ftpserv”, it will instantly launch an ftp service so that any user on your network can open up an FTP client and connect to that directory via FTP file transfer. Here is Filezilla connected to my laptop computer after I enabled the service on the laptop through the “sfk ftpserv” command.
These are just a few of the cool things you can do with sfk. If you load it onto a USB drive, just think of the powerful commands at your fingertips no matter what computer you are on. Plug in your USB stick and use sfk commands to launch and instant web service, or to quickly scan through a collection of documents, looking for specific words and joining together multiple files with just one or two quick command lines.
Swiss File Knife is the swiss army knife of command line programming tools, and it’ll make your life a whole lot easier. Give it a shot and let us know which commands you like best. Share your thoughts in the comments section below.
Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.