working on it ...


Explore Public Snippets

Sort by

Found 11k snippets matching: directory

    public by lbottaro modified May 2, 2013  901550  60  8  1

    How to remove all checked out files in clearcase

    This cleartool command lists all the checkout files (both from the current directory and from the entire view) searching in each directory or vob path. For each element found, it invokes the command to remove the checkout.
    # Remove ALL checked out files from view in the entire vobs
    cleartool lsco -cview -me -avobs -short | xargs cleartool unco -rm 
    # Remove ALL checked out files from the current directory on only
    cleartool lsco -cview -me -rec -short | xargs cleartool unco -rm 

    public by lbottaro @ Amazon_AWS_Python_API modified Aug 1, 2013  304345  0  8  0

    Amazon S3 Aws - How to download a file from a bucket to a target directory

    This code shows how to download a file from an existing bucket invoking the boto python API, saving to a target directory. You need to specify the filename and path where to save the data. [How to create a bucket]( [How to upload a file to a bucket](
    # This downloads the object foobar.pdf and saves it in /home/luca/documents/
    key = bucket.get_key('foobar.pdf')

    public by cghersi modified May 4, 2013  264194  2  5  0

    Bash command to get current directory


    public by lbottaro modified Sep 2, 2013  247322  3  7  0

    Lock and synchronization in python

    This example shows how to deal with lock in python parallel programming. Here we want to calculate the disk occupancy for a given directory in Linux OS, evaluating the disk occupancy for any subdirectory using threads. Note the usage of lock mechanism to ensure atomic operation on the total sum.
    import os
    import string
    import threading
    from threading import Thread
    disk_usage = 0
    lock = threading.Lock()
    for dir in os.popen('ls -d *').readlines():
        print "Dir: " + dir
        t = Thread(target=methodToBeExecutedInParallel, args=(dir,))
        #Join all existing threads to main thread.
        for thread in threading.enumerate():
            if thread is not threading.currentThread():
        print "Disk usage = " + str(disk_usage)
    # Function invoked by each thread
    def methodToBeExecutedInParallel(directory):
        print "Working on dir = " + directory
        cmd = 'du -s ' + directory
        line = os.popen(cmd).readlines()[0]
        dirUsage = int(line.split()[0])
        print "Acquiring lock for "+directory+"..."
        with lock:
            print "Acquired lock for "+directory
            global disk_usage
            disk_usage += dirUsage
        print "Disk usage = " + str(dirUsage)

    public by Charles Peter Nystrom modified Feb 19, 2016  202118  3  3  0

    Replace string in all files within the current directory. - PowerShell

    Replace string in all files within the current directory. - PowerShell: gistfile1.txt
    $stringToReplace = "foo"
    $replaceWith = "bar"
    Get-ChildItem | ForEach-Object{ $pathToFile = $_.FullName; (get-content $pathToFile) | % { $_ -replace $stringToReplace, $replaceWith } | set-content $pathToFile }

    public by DanielOgbuagu modified Jun 28, 2015  201724  1  5  0

    Adding a *.jar file (originating from java-wrapped C++ code) to an SBT project classpath

    I thought using unmanaged dependencies in SBT projects was simply dropping a jar file into the lib directory, until I bought an SDK for a biometric device. Both the C++ and the Java packages were provided. I opted for the Java package, copying the provided jar file and the JNI (*.so) files into the appropriate locations and configuring the ja
     * In my <code>build.sbt</code> file, I appended a blank line and then the following:
    libraryDependencies += "groupID" % "artifactId" % "revision" from "file:///home/Danogbuagu/Projects/biometric-lib/filename.jar"
    // where,
    // groupID for example is like: com.zigzagcompany 
    // artifactId for example is like: zigzag
    // revision for example is like: 1.3.4
    // Remember the line befor the code and that after.

    public by lbottaro modified Feb 6, 2014  7003  1  7  3

    Linux one liner bash code to detect file or directory from a given list

    This bash code shows how to detect if a given item in a list returned by a command is actually a file or a directory, without affecting the output format. In this case, xargs is used to pass the '{}' reference to a shell script executed for each line returned by the tree command.
    tree -if --noreport /home/ | xargs -I '{}' sh -c 'if [ -d {} ]; then echo "Dir {}"; else echo "File {}"; fi'  

    public by lbottaro modified Oct 17, 2013  4438  0  7  0

    How to find and remove directories in windows batch command

    The script will search for a given path and returns the name of folders found. The script may remove the directory found (with or without prompt)
    @echo off
    set m_path="C:\Users"
    if exist %m_path% (
    cd %m_path%
    echo FOUND %m_path%
    REM pippo
    for /F %%i in ('dir obj /s /b') do (
    echo "dir %%i"
    REM Remove dir without prompt
    rmdir %%i /s /q
    REM Remove dir with prompt
    REM rmdir %%i /s

    public by bobby modified Nov 14, 2014  24499  0  3  0

    Lints all PHP files recursively from a starting directory

    Lints all PHP files recursively from a starting directory: Recursive PHP Lint
    find ./ -type f -name \*.php -exec php -l {} \; | grep "Errors parsing ";

    public by MarcoDeMagistris modified Jun 20, 2013  2514  0  6  0

    DirectoryStream - list all the contents of a directory

    You can list all the contents of a directory by using the newDirectoryStream(Path) method. Added a Directory Filter.
    public class myLogDirectory{
    	 * It is a inner class used to create a Directory Filter 
    	 * @author emadema
    	public static class  myFileFilter implements DirectoryStream.Filter<Path>{
    		public boolean accept(Path path) throws IOException {
    			return (Files.isDirectory(path)); //List only directory	
    			//return false;
    	 * Find subfolders in @param directoryname and
    	 * creates filelist structure
    	 * @throws IOException
    	public void DirectoryList(String directoryname) throws IOException{
    		DirectoryStream<Path> stream = Files.newDirectoryStream(new File(directoryname).toPath(), new myFileFilter());		
    		for (Path entry: stream)
    	public static void main(String[] args) {
    		try {
    			new myLogDirectory().DirectoryList("c:\\test");
    		} catch (IOException x) {
    • Public Snippets
    • Channels Snippets