My working folder is e:\photos
It has 20 sub-folders.
I have a video list text file "familymovies.txt" to parse for file names.
The batch file will search e:\photos for the first occurance of each file and move it to e:\photos\family-movies
It would be nice to log.txt two things:
1. Original full path and file name if found and moved.
2. List of any file names NOT foundMany thanks,
GregS
does this list of filenames have the full path as well like: E:\Photos\Sub-Folder\File.ext
or is it just "File.ext"?
No folder names. Simply the filename.
Got this ugly powershell script you can give a try..
The logging is really bad, but it works tho, it will copy the files if the names match.$PSScriptRoot is the folder the script is located in, so the log.txt will be in the same folder as the script.
Only have to change the paths with "E:\" in them if neededLet me know how it goes if you test it
# Script below
Start-Transcript -Path $PSScriptRoot\log.txt -Append -Force -NoClobber
foreach ($Line in (Get-Content -Path "E:\familymovies.txt")) {
$File = Get-ChildItem -Path "E:\Photos" -Filter "*$Line*" -Recurse
$Path = $File.FullName
$Test = Test-Path $Path
if ($Test -eq $True) {
Move-Item -Path $Path -Destination "E:\Photos\Family-Movies" -Force
Write-Host "Moved file: $Path"
} else {
Write-Host "Not found: $Line"
}
}Stop-Transcript
Pause
message edited by Kilavila
If you just want to move all video files from these folders to that new folder there is a better way tho: $Folder = Get-ChildItem "E:\Photos" -Recurse
New-Item "E:\log.txt"foreach ($i in $Folder){
if ($i.Extension -eq '.avi' -or $i.Extension -eq '.mp4' -or $i.Extension -eq '.mov'){
$File = $i.FullName
Move-Item -Path $File -Destination "E:\Photos\Family-Movies"
Add-Content -Path "E:\log.txt" -Value "Copied file: $File to: E:\Photos\Family-Movies"
}
}This will move all .avi, .mp4 and .mov files from E:\Photos to E:\Photos\Family-Movies
Is this a batch file?
It doesn't run.message edited by GregSch
oh, no its powershell.
save it as .ps1 and run file with powershell.exeEdit:
You can also run powershell, then drag and drop the script into powershell and press enter.message edited by Kilavila
Can this batch file be modified to work? @echo off & setlocal enabledelayedexpansion
type nul>e:\photos\log.txt
set log=e:\photos\log.txt
set list=familymovies.txt
set cnt=0
set number=0
for /f "delims=" %%a in ('type %list%') do (
set /A cnt +=1
set file!cnt!=%%a
)
E:
cd E:\Photos
:LOOP
if %number%==%cnt% exit /b
set /A number +=1
dir /s !file%number%! || echo.!file%number%!>> e:\photos\log.txt
Goto :LOOP
You can use batch, but i just know the basics tho as im not using batch scripts myself.