Popular recipes tagged "directory" but not "change" and "gui"http://code.activestate.com/recipes/tags/directory-change-gui/2017-03-27T13:20:41-07:00ActiveState Code RecipesSimple directory list command with filename wildcard support (Python)
2016-12-02T20:52:56-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580724-simple-directory-list-command-with-filename-wildca/
<p style="color: grey">
Python
recipe 580724
by <a href="/recipes/users/4173351/">Vasudev Ram</a>
(<a href="/recipes/tags/commandline/">commandline</a>, <a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/filesystem/">filesystem</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/utilities/">utilities</a>).
</p>
<p>This recipe shows a simple directory listing program. It can accept multiple command-line arguments specifying filenames. These filenames can include wildcard characters like * (asterisk) and ? (question mark), as is common in OS command shells like bash (Unix) and CMD (Windows). Tested on Windows but should work on Unix too, since it uses no OS-specific functions, or rather, it does use them, but that happens under the hood, within the libraries used.</p>
File selector dialog in batch (Batch)
2017-03-27T13:20:41-07:00Antoni Gualhttp://code.activestate.com/recipes/users/4182514/http://code.activestate.com/recipes/580665-file-selector-dialog-in-batch/
<p style="color: grey">
Batch
recipe 580665
by <a href="/recipes/users/4182514/">Antoni Gual</a>
(<a href="/recipes/tags/batch/">batch</a>, <a href="/recipes/tags/directory/">directory</a>).
Revision 2.
</p>
<p>Runs mshta hidden to open a file dialog and get the path of the file selected. No parameters can be passed to the dialog.
EDITED: I did a subroutine with the snippet</p>
Shortcut Utility (Python)
2015-03-29T20:45:57-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/579041-shortcut-utility/
<p style="color: grey">
Python
recipe 579041
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/desktop/">desktop</a>, <a href="/recipes/tags/directories/">directories</a>, <a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/tkinter/">tkinter</a>, <a href="/recipes/tags/ui/">ui</a>, <a href="/recipes/tags/utilities/">utilities</a>, <a href="/recipes/tags/utility/">utility</a>).
</p>
<p>I dislike filling my desktop with shortcut icons in Windows.
This code enables creating shortcuts in a CSV file.</p>
Find Duplicate Files (Python)
2014-10-12T21:14:05-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578950-find-duplicate-files/
<p style="color: grey">
Python
recipe 578950
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/dictionary/">dictionary</a>, <a href="/recipes/tags/directories/">directories</a>, <a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/disk/">disk</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/utility/">utility</a>).
</p>
<p>Finds duplicate files which have same size and same content in the same directory or two different directories.</p>
Dynamically create a dictionary of ascending paths (Python)
2012-12-03T22:50:47-08:00Scott S-Allenhttp://code.activestate.com/recipes/users/4181178/http://code.activestate.com/recipes/578354-dynamically-create-a-dictionary-of-ascending-paths/
<p style="color: grey">
Python
recipe 578354
by <a href="/recipes/users/4181178/">Scott S-Allen</a>
(<a href="/recipes/tags/bootstrap/">bootstrap</a>, <a href="/recipes/tags/dictionary/">dictionary</a>, <a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/dynamic/">dynamic</a>, <a href="/recipes/tags/flexible/">flexible</a>, <a href="/recipes/tags/path/">path</a>, <a href="/recipes/tags/portable/">portable</a>).
</p>
<p>Ripped from a more elaborate bootstrap script. A sequential set of parent-directories were required for environment variables and subsequent, portable. auto-discovery. </p>
Recursive find and replace in all files in directory with regex (Python)
2013-03-21T12:33:44-07:00ccpizzahttp://code.activestate.com/recipes/users/4170754/http://code.activestate.com/recipes/578312-recursive-find-and-replace-in-all-files-in-directo/
<p style="color: grey">
Python
recipe 578312
by <a href="/recipes/users/4170754/">ccpizza</a>
(<a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/recursion/">recursion</a>, <a href="/recipes/tags/regular_expressions/">regular_expressions</a>, <a href="/recipes/tags/replace/">replace</a>).
</p>
<p>Search and replace files recursively in a given directory. Accepts regular expressions as search and replacement patterns.</p>
<p><strong>Example usage</strong>:</p>
<pre class="prettyprint"><code>python find_replace_regex.py ".", "<span[^>]*>", "<div>", "*.html" backup
</code></pre>
<p><strong>Note</strong>:
On win32 the <code><</code> and <code>></code> symbols are interpreted by the shell as input/output redirection even when they are surrounded with single or double quotes, and therefore need to be escaped with the caret character <code>^</code>.</p>
Create replica of the existing directory structure with only specified extension files. (Python)
2012-11-16T08:30:31-08:00Achal Rastogihttp://code.activestate.com/recipes/users/4183889/http://code.activestate.com/recipes/578303-create-replica-of-the-existing-directory-structure/
<p style="color: grey">
Python
recipe 578303
by <a href="/recipes/users/4183889/">Achal Rastogi</a>
(<a href="/recipes/tags/bioinformatics/">bioinformatics</a>, <a href="/recipes/tags/biology/">biology</a>, <a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/fileextensions/">fileextensions</a>, <a href="/recipes/tags/replica/">replica</a>).
Revision 2.
</p>
<p>The program creates a replica of existing directory structure with specified extension files only. The program maintains the directory-sub-directory architecture while executing. User has to provide two arguments, First the path of existing directory,whose replica has to be created and Second, the path of directory, where the replica has to be created.
This program is developed to fetch files with ".pl" (perl) extension, while maintaining the directory-sub-directory architecture. User can modify it, with his/her interested file extension, like ".txt", ".doc", etc.</p>
Ghoster - Windows program to create 0kb clone of folder or drive (Python)
2012-09-02T13:30:29-07:00commentator8http://code.activestate.com/recipes/users/4182761/http://code.activestate.com/recipes/578251-ghoster-windows-program-to-create-0kb-clone-of-fol/
<p style="color: grey">
Python
recipe 578251
by <a href="/recipes/users/4182761/">commentator8</a>
(<a href="/recipes/tags/clone/">clone</a>, <a href="/recipes/tags/copy/">copy</a>, <a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/windows/">windows</a>).
</p>
<p>A program that will create a "ghost" of a given directory or drive on windows systems
(easily adaptable to unix etc) to a given destination. This will consist of a copy of all folders and files with only names and extensions retained, not size.
This allows browsing of a remote drive or network location when offline.</p>
CGI Directory Contents (Python)
2012-07-02T22:38:31-07:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578183-cgi-directory-contents/
<p style="color: grey">
Python
recipe 578183
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/archive/">archive</a>, <a href="/recipes/tags/cgi/">cgi</a>, <a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/old/">old</a>).
</p>
<p>CGI Directory Contents was a simple experiment meant to work similarly to the <code>os.listdir</code> function in Python. This is committed for archival to be run under Python 2.5 or later versions.</p>
Simple directory tree view generator (Python)
2012-03-09T09:02:21-08:00ajaymenon.khttp://code.activestate.com/recipes/users/4181225/http://code.activestate.com/recipes/578065-simple-directory-tree-view-generator/
<p style="color: grey">
Python
recipe 578065
by <a href="/recipes/users/4181225/">ajaymenon.k</a>
(<a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/tree/">tree</a>).
</p>
<p>An extremely simple tree-view generator for a directory</p>
Directory Deleter (Python)
2011-07-27T15:23:29-07:00mJackhttp://code.activestate.com/recipes/users/4178791/http://code.activestate.com/recipes/577809-directory-deleter/
<p style="color: grey">
Python
recipe 577809
by <a href="/recipes/users/4178791/">mJack</a>
(<a href="/recipes/tags/delete/">delete</a>, <a href="/recipes/tags/directories/">directories</a>, <a href="/recipes/tags/directory/">directory</a>).
</p>
<p>This small program lets a user delete a directory on their Windows system.
Also good for learning from.</p>
Destroying Directories (Python)
2011-04-21T02:55:31-07:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577670-destroying-directories/
<p style="color: grey">
Python
recipe 577670
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/delete/">delete</a>, <a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/recursion/">recursion</a>).
</p>
<p>When files and directories need to be securely deleted, there are many tools in existence that people can turn to for their needs. While there are many ways one might go about manually deleting files and removing directories, this recipe provides a sample implementation of what may be considered throughout the process. This destructive command line program takes the path to a directory as a command line argument and does its best to render it and its contents unrecoverable. There are much better and inclusive applications than this one, but those wishing to write their own utilities may take some inspiration from this recipe while writing their own tools.</p>
<p>If there are any recommendation for this recipe or if anyone wishes to down-vote this recipe, please provide corrective criticism showing the the program's faults and give suggestions on how you would fix any problems that it might have.</p>
user and root directory logfile (Python)
2011-03-22T10:00:49-07:00justin drakehttp://code.activestate.com/recipes/users/4177409/http://code.activestate.com/recipes/577619-user-and-root-directory-logfile/
<p style="color: grey">
Python
recipe 577619
by <a href="/recipes/users/4177409/">justin drake</a>
(<a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/log/">log</a>, <a href="/recipes/tags/time/">time</a>, <a href="/recipes/tags/user/">user</a>).
</p>
<p>script to retrieve time, current user, and root of directory
output to spam.txt</p>
<p>want to add more like windows version, bios info and other useful diagnostic information </p>
<p>free to use and modify
welcome any advice or corrections
learning python hope this turns into a script to create a organized personal report of customer's pc</p>
Directory Size (Console) (Python)
2011-02-09T13:29:56-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577566-directory-size-console/
<p style="color: grey">
Python
recipe 577566
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/commandline/">commandline</a>, <a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/sizeof/">sizeof</a>, <a href="/recipes/tags/tree/">tree</a>).
</p>
<p>Have you ever wanted to find out how much room a particular directory was taking up on your hard drive? A roommate of mine in college was having trouble keeping track of where his hard drive space is going, so the following program provided a solution that allows a brief overview of a directory's size along with all of its children. A tree view is printed out in ASCII characters showing the relationship of each directory along with its size in a format easily readable to humans. The output can always be redirected to a text file if it needs to be saved for viewing later on.</p>
Recurse copy file (Python)
2010-12-09T09:52:36-08:00boussardhttp://code.activestate.com/recipes/users/4176187/http://code.activestate.com/recipes/577493-recurse-copy-file/
<p style="color: grey">
Python
recipe 577493
by <a href="/recipes/users/4176187/">boussard</a>
(<a href="/recipes/tags/copy/">copy</a>, <a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/recurse/">recurse</a>).
</p>
<p>Automate copy and paste file with erase the content of file if exists on destination directory. Like shutil.copytree but when dir is exists on destination tree , don't fail, just pass.</p>
Getting the SHA-1 (or MD5) hash of a directory (Python)
2009-12-06T19:02:40-08:00Stephen Akikihttp://code.activestate.com/recipes/users/4172143/http://code.activestate.com/recipes/576973-getting-the-sha-1-or-md5-hash-of-a-directory/
<p style="color: grey">
Python
recipe 576973
by <a href="/recipes/users/4172143/">Stephen Akiki</a>
(<a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/getting/">getting</a>, <a href="/recipes/tags/hash/">hash</a>, <a href="/recipes/tags/md5/">md5</a>, <a href="/recipes/tags/sha_1/">sha_1</a>, <a href="/recipes/tags/the/">the</a>).
Revision 4.
</p>
<h5><a href="http://akiscode.com/articles/sha-1directoryhash.shtml" rel="nofollow">http://akiscode.com/articles/sha-1directoryhash.shtml</a></h5>
<p>By definition a cryptographic hash is, "a deterministic procedure that takes an arbitrary block of data and returns a fixed-size bit string, the (cryptographic) hash value, such that an accidental or intentional change to the data will change the hash value". </p>
<p>Usually these hashes are used on files to "fingerprint" them, but in order to do the same to a directory you have to do something like this: </p>
dealing with directory paths with ~ (Python)
2010-06-16T23:17:20-07:00roopeshvhttp://code.activestate.com/recipes/users/4174204/http://code.activestate.com/recipes/577270-dealing-with-directory-paths-with/
<p style="color: grey">
Python
recipe 577270
by <a href="/recipes/users/4174204/">roopeshv</a>
(<a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/expanding/">expanding</a>, <a href="/recipes/tags/paths/">paths</a>).
Revision 2.
</p>
<p>Dealing with directory paths which start with <code>~</code> which are passed as paramaters, to <code>os</code> module functions.</p>
<p>Here is what I think python doesn't do for me:</p>
<pre class="prettyprint"><code>>>> import os
# suppose my home = curdir = /home/rv
>>> os.path.abspath('.')
'/home/rv'
</code></pre>
<p>Now if I want to go to folder <code>/home/rv/test</code> if there is no folder by name
/home/rv/~/test/</p>
<pre class="prettyprint"><code># This is what happens by default.
>>> os.path.abspath('~/test')
'/home/rv/~/test'
>>> os.chdir('/home/rv/some/dir')
# doesn't matter if the resulting path exists or not.
>>> os.path.abspath('~/test')
'home/rv/some/dir/~/test'
</code></pre>
<p>This would be more sensible I guess:</p>
<pre class="prettyprint"><code># if /home/rv/~/test doesn't exist
>>> os.path.abspath('~/test')
'/home/rv/test'
</code></pre>
Windows TREE Emulator (Python)
2010-03-08T12:57:10-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577091-windows-tree-emulator/
<p style="color: grey">
Python
recipe 577091
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/listing/">listing</a>, <a href="/recipes/tags/tree/">tree</a>, <a href="/recipes/tags/utility/">utility</a>).
Revision 2.
</p>
<p>Windows has a nice command line program capable of printing out a tree of the the folders, sub-folders, and possibly the files of a directory. The tool below mimics a behavioral subset of TREE, Microsoft's inspiring utility. This version is designed to output a similar tree and should be compatible on Windows, Linux, and Macintosh. In case it is not used correctly, a simple usage message will be printed (without notes on the optional "/F" switch). ASCII characters are used.</p>
PDF a Directory of Images using Reportlab (Python)
2009-04-12T08:35:10-07:00andrew.canithttp://code.activestate.com/recipes/users/4169843/http://code.activestate.com/recipes/576717-pdf-a-directory-of-images-using-reportlab/
<p style="color: grey">
Python
recipe 576717
by <a href="/recipes/users/4169843/">andrew.canit</a>
(<a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/images/">images</a>, <a href="/recipes/tags/pdf/">pdf</a>).
</p>
<p>Walk through a directory PDFing Images</p>
Directory Walking File Renamer (Python)
2008-12-28T08:04:34-08:00mickey Hadickhttp://code.activestate.com/recipes/users/4168585/http://code.activestate.com/recipes/576597-directory-walking-file-renamer/
<p style="color: grey">
Python
recipe 576597
by <a href="/recipes/users/4168585/">mickey Hadick</a>
(<a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/rename/">rename</a>).
</p>
<p>Walk through a list of directories and rename the files within those directories based on the directory name and an index value. Useful for managing photos when downloaded from a camera into directories based on the shooting date.</p>