I created a little batch script that will check a specific folder. This folder contains subfolders per customer, and in this subfolders there are files.
First it will create another subfolder underneath the customer folder named old.
Next, it should loop each customer folder and move the files older than 1 day to the old subfolder.
My script runs quite fine, but i'm unable to get my output correct.
if I put my forfiles command to "cmd /c Move XYZ | echo @path" I get an error saying I tried to write to an unexisting pipe. If I move the echo before the "move", the files are placed, but I get no output.
As a second problem, I also get a message stating there are no result for the forfiles function, which I can hide with 2>NUL, but I am unsure wether or not I would lose the result of the echo @path as well.
If I was able to get the output correct, it would be nice to only show the echo %%m for the folders where there actually are files, but that's just a nice to have :)
here is my script:
for /D %%m in (*) DO md "%%m"\old 1>NUL 2>&1
for /D %%m in (*) DO forfiles -P "%%m" -D -1 -M *.* -C "cmd /c move /Y @path old/" | echo %%m:
oh, btw, if this is easier to accomplish using powershell, i'm open to suggestions, i'm just not into powershell yet :)