Discussion:
robocopy : move files in subfolders according to extension
(too old to reply)
Ammammata
2021-09-30 08:01:04 UTC
Permalink
Hello

as per subject, I'd like (if possible) to move about 45 thousands files in
related subfolders according to their extension

subfolders have already been created

thank you
--
/-\ /\/\ /\/\ /-\ /\/\ /\/\ /-\ T /-\
-=- -=- -=- -=- -=- -=- -=- -=- - -=-
........... [ al lavoro ] ...........
JJ
2021-09-30 10:55:31 UTC
Permalink
Post by Ammammata
Hello
as per subject, I'd like (if possible) to move about 45 thousands files in
related subfolders according to their extension
subfolders have already been created
thank you
It's possible. See its documentation. Type: robocopy /?
Ammammata
2021-09-30 12:34:18 UTC
Permalink
Il giorno Thu 30 Sep 2021 12:55:31p, *JJ* ha inviato su alt.msdos.batch il
Post by JJ
It's possible. See its documentation. Type: robocopy /?
well, thank you, but actually at the end I did it manually because the
number of different extensions was limited

then, in each folder, I ran a partially modified code to split the files in
subfolders yyyy-MM-dd, according to last modification date, using
powershell

source:
https://www.thomasmaurer.ch/?p=6984


--- start of code ---
# Get the files which should be moved, without folders
$files = Get-ChildItem '.\' -Recurse | where {!$_.PsIsContainer}

# Target Filder where files should be moved to. The script will
automatically create a folder for the year and month.
$targetPath = '.\'

foreach ($file in $files)
{
# Set Directory Path
$Directory = $targetPath + $file.LastWriteTime.Date.ToString("yyyy-MM-dd")

# Create directory if it doesn't exsist
if (!(Test-Path $Directory))
{
New-Item $directory -type directory
}

# Move File to new location
$file | Move-Item -Destination $Directory
}
--- end of code ---
--
/-\ /\/\ /\/\ /-\ /\/\ /\/\ /-\ T /-\
-=- -=- -=- -=- -=- -=- -=- -=- - -=-
........... [ al lavoro ] ...........
pyotr filipivich
2021-09-30 16:50:46 UTC
Permalink
Post by Ammammata
Hello
as per subject, I'd like (if possible) to move about 45 thousands files in
related subfolders according to their extension
subfolders have already been created
thank you
robocopy source target /if *.%extension% /move
--
pyotr filipivich
This Week's Panel: Us & Them - Eliminating Them.
Next Month's Panel: Having eliminated the old Them(tm)
Selecting who insufficiently Woke(tm) as to serve as the new Them(tm)
Loading...