K
K
keeplod2020-10-22 16:54:51
PowerShell
keeplod, 2020-10-22 16:54:51

A task has arrived and I can’t execute it on cmd and ps in any way, who can help?

The essence of the task, there are 100 files 1file.log; 2file.log; 3file.log; 4file.log...
there are 100 more folders 1folder; 2folder; 3folder; 4folder...
(all files and folders on the desktop)

Use PS or CMD to scatter files into folders named 1file=>1folder; 2file=>2folder... Tell me
or help someone who can, thanks in advance =)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MaxKozlov, 2020-10-22
@keeplod

1..100 | foreach-Object {
   Move-Item "Path/To/File/$($_)file.log" -Destination "Path/To/Folder/$($_)folder"
}

So, for the sake of sporting interest, on CMD :)
@for /L %%a IN (1,1,100) do @echo move "source/dir/%%afile.log" "dest/dir/%%afolder"

echo, of course, remove

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question