Answer the question
In order to leave comments, you need to log in
Move each file to its own folder and rename folder to name from filename?
There is a directory with a huge number of files, the files have the name: "Vasya_file_creation_date.ts", "Fedya_file_creation_date.ts", etc. the dates of creation of files in the names are different, so, it is necessary that all files with the name Vasya, but with different dates of the creation of files in the names, were transferred to a folder named Vasya, the folder should also be created by itself, the files from "Fedya" were transferred to the folder Fedya and etc., I think the landmark is the definition of the folder name and the identity of the files that need to be transferred to this folder is the first character "_".
Answer the question
In order to leave comments, you need to log in
Iterate through all the files in a directory with a loop for
.
You can select substrings in the file name using for /f
, setting the appropriate separator.
Create directory md
Move file: move
For details:
for /?
md /?
move /?
setlocal /?
I found it for a similar task:
The folder contains files
First.mp3
Second.mp3
Third.mp3
Fourth.mp3
the code is this:
@echo off
FOR %%f IN (*.mp3) DO md "%%~nf" & move /Y "%%f" "%%~nf\"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question