I need the bat file to scan a directory and look at all of the subfolders. If a subfolder contains any PDFs then I need that parent folder to be moved into a new location and then deleted from the old location. Is this even possible via bat? Sorry i'm just starting with bat file writing.
1 Answer
For sure it is possible! Look if you have the chance to use powershell instead of batch (which is old). Powershell is more clearer to read than batch and most of the time you have access to powerfull tools.
Gonna give you a good help to start (if you use Powershell):
Get-ChildItem -Path "c:\folder\to\start\scan" -Filter *.pdf -Recurse | select-object -unique directory | Foreach-Object{echo $_.Directory.FullName} | Out-String
After you just need to find a way to move your folders
Credits for this command:
https://stackoverflow.com/questions/13126175/powershell-get-full-path-of-the-files https://stackoverflow.com/questions/7609884/delete-duplicate-string-with-powershell