logo
down
shadow

How to move folders if they contain a certain file?


How to move folders if they contain a certain file?

By : user2955465
Date : November 22 2020, 10:40 AM
To fix this issue I'm writing some (ugly) code in batch to rearrange files between folders.
code :
for /r "e:\videos\catalogar\" %%F in (serie.txt) do (


Share : facebook icon twitter icon
How to create folders using file names and then move files into folders?

How to create folders using file names and then move files into folders?


By : java101
Date : March 29 2020, 07:55 AM
this will help gregseth's answer will work, just replace trim with xargs. You could also eliminate the if test by just using mkdir -p, for example:
code :
for f in *.txt; do
    band=$(echo "$f" | cut -d'-' -f1 | xargs)
    mkdir -p "$band"
    mv "$f" "$band"
done
Windows batch file to move each file to a numbered folder and zip all folders

Windows batch file to move each file to a numbered folder and zip all folders


By : Tudi
Date : March 29 2020, 07:55 AM
hop of those help? Here's an example of how to include an incremental counter in your batch file. This should help you get going on the rest of the batch file:
code :
@Echo off
setlocal EnableDelayedExpansion
set counter=1
for %%a in ("*.*") do (
  set suffix=00000!counter!
  echo %%a  - This is counter number: !suffix:~-5!
  set /a counter+=1
)
Move file to folders while creating folders

Move file to folders while creating folders


By : Simona
Date : March 29 2020, 07:55 AM
Hope this helps I have some files and I want to move them to some folders. I made the code which create these folders based on number of files. How can I move the files to each folder (better if directly when creating each one) ? , os.rename() or shutil.move(), they both have the same syntax.
code :
os.rename("path/to/current/file.foo", "path/to/new/desination/for/file.foo")
shutil.move("path/to/current/file.foo", "path/to/new/destination/for/file.foo")
import os
import errno

src = (os.path.expanduser('~\\Desktop\\output8\\singola\\'))

causali = os.listdir(src)
causali.sort(key=lambda x: int(x.split('.')[0]))

for file in enumerate(causali):
   try:
        id_folder = os.makedirs(os.path.expanduser('~/test_move/{}'.format(file[0])))
        os.rename(os.path.expanduser('~\\Desktop\\output8\\singola\\{}'.format(file[1])),os.path.expanduser('~\\Desktop\\output8\\singola\\{}\\{}'.format(file[0],file[1])))
   except OSError as e:path/to/new/destination/for/file
        if e.errno != errno.EEXIST:
            raise
Can i move file for two folders? Dropzone.js

Can i move file for two folders? Dropzone.js


By : Taher Amin
Date : March 29 2020, 07:55 AM
it helps some times My dropzone form , First, let's see what you're doing wrong:
code :
// You're moving the original file right here, this is fine
if(move_uploaded_file($source_path, $target_path)) {
    $db->insert("images", $array);
}

// This won't work, because you're trying to access orginal file (moved already)
image::resize($source_path, "img/clients/thumbs/".$targetFile, 100, 100);
$db->insert("log", array("action" => "image", "inserted_on" => date("Y-m-d 
    H:i:s"), "users_id" => $_POST["users_id"], "clients_id" => $id));    

// Now you're trying to move again the original file
if(move_uploaded_file($source_path, $target_path1)) {
    echo "Success";
}
if(!empty($_FILES)) {
    $fileName = $_FILES['file']['name'];
    $source_path = $_FILES['file']['tmp_name'];
    $fileExtension = pathinfo($fileName, PATHINFO_EXTENSION);
    $targetFile = $id."_".$fileName;
    $target_path = "img/clients/".$targetFile;
    $array["filename"] = $targetFile;
    $array["main"] = (int)($db->query("SELECT * FROM images WHERE clients_id = :clients_id;", array("clients_id" => $id), false) == 0);;
    $array["clients_id"] = $id;

    // Move original file
    if(move_uploaded_file($source_path, $target_path)) {
        $db->insert("images", $array);

        // Create thumb only if the file was moved, otherwhise you'll get errors
        // Your source is the file moved, not the one on temp folder
        image::resize($target_path, "img/clients/thumbs/".$targetFile, 100, 100);

        $db->insert("log", array("action" => "image", "inserted_on" => date("Y-m-d 
            H:i:s"), "users_id" => $_POST["users_id"], "clients_id" => $id));    
    }
}
Batch file to move folders to sub-folders

Batch file to move folders to sub-folders


By : Noah Jarnigan
Date : March 29 2020, 07:55 AM
I wish this help you Here is my current folder structure:
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org