Put Your Command Line On Steroids With Swiss File Knife [Windows]

Ryan Dube 02-12-2011

command line programmingSometimes, 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 3 Awesome Things You Can Do With Windows Scripting Whether you work in the IT field, as a web designer, or if you are just a student or regular office worker, Windows Scripting has something to offer you. Of course Applescript does as well,... Read More , 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.

command line programming


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.

command line software

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

command line software

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]”.


command line software

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.
command line tools
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.


command line tools

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.
Put Your Command Line On Steroids With Swiss File Knife [Windows] sfk81
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.

command line tools

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.
command line programming
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.

Whatsapp Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Johnny Boi
    December 15, 2011 at 3:41 am

    wait can i get some help here? i know how to change the variables but how do i just include the path? like what do you mean? include both cmd.exe and sfk.exe in the same argument? please explain, cuz it says up there setting up sfk is really easy, then you show a picture, that still doesnt really help me. thanks

    • Ryan Dube
      December 19, 2011 at 3:33 pm

      Johnny, go to control panel, system, then possbily "Advanced" - find the Environment Variables button. In there you'll see User Variables and System Variables.

      Inside the System variables box, find PATH, double click the value, and append the path where you installed SFK on your PC. In my case it was c:sfk. This allows you to run the program straight from your command prompt no matter what directory you're in.

      Does that all make sense? Let me know how it goes...

      • Johnny Boi
        February 1, 2012 at 11:31 pm

        i dont know which one to edit the environment variables, also which characters to use to append the entire file path to sfk. but i can just right-shift and "open command prompt" on sfk.exe and it works fine. i just cant figure out which variable to change,
        thanks for the help! 

  2. Phil Fot
    December 5, 2011 at 3:16 am

    Very nice. Thanks!