Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the file sorting and finishing machine by batch processing

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you the "batch processing how to achieve the file categorizer", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "batch processing how to achieve the file categorizer" this article.

The code is as follows:

@ echo off

Title file categorizer-test

:: =

: objective:

::

Classifies files under the current directory and all its subdirectories.

::

:: collate the results:

::

Under the current directory and its subdirectories, take the name of the file type in the folder as the folder name, and in the file

:: create folders such as exe files and rar files under the directory in which different types of files are moved to

:: under the corresponding folder.

:: if a new file is added later, when you run this script again, if the corresponding folder already exists in that location

:: the newly added files will be saved under this folder; if there is no corresponding folder, a new folder will be created to save

:: the file.

::

:: the features that will be implemented in the next version:

::

: ① collates the subdirectories with the current directory as the starting point and the specified layer depth

:: ② collates files other than the specified type.

::

:: update history

::

: 2006-12-16

::

:: added the function of no longer sorting files that have been classified, which is v1.1

::

: 2006-12-15

::

On the basis of only sorting out different types of files in the current directory, write out the

:: code for operating different types of files, this is V1.0

:: =

Set "file_route=%cd%"

For / f "delims="% I in ('dir / amurd / b / s / oe') do (

Set "nx_name=%%~nxi"

Call: build_dir% ~ xi "% ~ dpi"

Set file_type=%%~xi

Set "file_route=%%~dpi"

)

Goto: eof

Rem = create folders by file type =

: build_dir

Set types=%1

Set route=%2

Set types=%types:~1%

Set "route=%route:~1,-1%"

Set "cd_name=%route:~0,-1%"

Rem = get the directory name where the file is located =

: get_cd_name

Set "cd_name_tmp=%cd_name:\ =%"

Set "cd_name=%cd_name:*\ =%"

If not "% cd_name%" = = "% cd_name_tmp%" goto get_cd_name

Compare the file type name with the directory name to determine which files have been sorted out

If "% cd_name%" = = "% types% file" goto: eof

:: determine whether the location of the file has changed

If% 2 else set chang_dir=yes&set file_type= = "% file_route%" (set chang_dir=) else set chang_dir=yes&set file_type=

:: determine whether the file to be processed is the batch file itself

If "% route%%nx_name%" = = "% ~ f0" (set file_self=yes) else set file_self=

:: determine whether the file type has changed

If "% 1" = = "% file_type%" (set same_type=yes) else set same_type=

If not defined chang_dir (

If not defined file

The above is all the contents of this article "how to realize the file sorting and finishing machine in batch processing". Thank you for your reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report