The Invent with Python Blog

Writings from the author of Automate the Boring Stuff.

Sat 28 August 2021

ccwd - A Copy Current Working Directory Command

Posted by Al Sweigart in programming   

In 2008 I created a small program meant to be run from a terminal window called ccwd which copies the current working directory to the clipboard. While the standard Unix command pwd will print the working directory (that is, the current folder the terminal is in), this will copy it to the clipboard. I found myself using it all the time when I needed to get the directory that I was in.

Example usage in the Windows Command Prompt:

Microsoft Windows [Version 10.0.19043.1165]
(c) Microsoft Corporation. All rights reserved.

C:\Users\Al>cd Desktop

C:\Users\Al\Desktop>ccwd

C:\Users\Al\Desktop>

At this point, C:\Users\Al\Desktop would be copied to the clipboard and could easily be pasted into other apps. I have the C source code and Windows executable here. ccwd.exe does not produce any output, and returns 0 on success and a nonzero value on failure.

C source code for Windows

ccwd.exe executable program

I recommend placing the ccwd.exe file in the C:\Windows folder or someplace on the system PATH.

Learn to program for free with my books for beginners:

Sign up for my "Automate the Boring Stuff with Python" online course with this discount link.