How to use internal commands to achieve file management

  
In Windows Explorer, for some complicated file or folder operations, we often need to use the mouse and keyboard to select commands in multiple ways to complete. And if you use Notepad combined with simple Windows internal commands, you can easily handle very complex file operations. Folder structure replication A company formed a department employee work data directory in the server last year. Its structure is a complex folder structure composed of departments and employees at all levels. New Year is coming, you need to build the same folder structure, but you don't need any data. How to complete this task? Assume that the department's 2012 working directory is the F-disk's “2012 General Catalogue”, and the 2013 new catalogue is ready to be named “F-disk” in 2013. The method of transferring the directory structure is as follows: Create a file (such as Make2013.TXT) in Notepad in the root directory of the F drive, and enter the following command (Figure 1): XCOPY F:\\2012Working Directory\\*.* F:\\2013 Work Directory/E/T After saving, change the file extension to BAT, get the Make2013.BAT file, double-click the file, and automatically generate all levels in the “2013 Work Directory” directory. Empty folders for departments and employees. Description: Of the two parameters in the above command, the /e parameter indicates that all subdirectories are copied, including empty directories. The /t parameter means that only the subdirectory structure (that is, the directory tree) is copied and the files are not copied. To copy an empty directory, you must use the /t parameter with the /e parameter in order to be effective. This is the skill of using the command parameters reasonably. Copying a certain type of file with a structure is also a company above, assuming that during the year, many types of documents are formed under the employee folders of each department. The file with the word "report" in the file name is the document of the leadership of a department. The leader needs a set of such information, and the complete department folder structure should be retained. How to copy it? Still assuming that the department's 2012 working directory is the F disk's "2012 general directory", the new directory for the leadership is ready to be named F disk "to Zhang Manager". The method of transferring the directory structure is as follows: Create a file (such as MakeZhang.TXT) in Notepad in the root directory of the F drive, and enter the following command (Figure 2): XCOPY F:\\2012 Work Directory\\*Report* .* F:\\ After saving the manager/S, change the extension of the file to BAT, get the MakeZhang.BAT file, double-click the file, and automatically generate the manager Zhang’s needs in the “To Manager Zhang” directory. Employee report documents that contain all levels of departments but only contain “reports” Description: Only one parameter /s is used in the above command line, which means copying non-empty directories and subdirectories. If you omit /s, xcopy will work in a directory and will not contain subdirectories of all levels. The “*reported*.*” is a wildcard to describe all files containing the words “reporting”, regardless of the location of the file name in the file name. Delete hidden files under all levels of folders We often perform Word document operations on hard disk or mobile hard disk, or download some data. During the operation, Word may generate some hidden temporary files, and the download software may also Some seed files are stored on disk as hidden files. These files have a certain amount of disk space, which will erode our precious space resources. So how do you clear these files that we can't see but that are useless to us? If the folder where we store the Word document is D:\\Personal Document, just use Notepad to create a batch file with the following contents in this directory (Figure 3). Double-click it to execute it. The parameters in the DEL D:\\personal document\\*.* /AH /S/F/Q command line are as follows: /F means to delete the read-only file; /S means to delete the specified file from all subdirectories; /Q means to Quiet mode deletion, no confirmation is required; /A means to select the file to be deleted according to the attribute, followed by the attribute description (R read-only file, S system file, H hidden file, A archive file), here because the hidden file is deleted , so specify H. The combination of /AH and /F means that even if the implicit file has an institutional attribute, it is deleted as well. If you want to delete an implicit file with system attributes, then add an /AS. Update the files in the directory by time. We can update the files by time with internal commands. That is, only files created or modified after a date in one folder are backed up to another folder. Other files are not copied. deal with. For example, to update the files in the I:\\Reports directory of the mobile hard disk with the files changed in the D:\\Rawdata directory of the hard disk after December 29, 2011, you only need to execute the following command at the command prompt (Figure 4): Xcopy D:\ awdata I:\ eports /d:12-29-2011 To update all the files that exist in \\Reports in the above example, regardless of the date, change the command line to the following: xcopy D:\ awdata I :\ eports /u If you only want to get the list of files updated after the 12-29-2011 date to be copied by the above command, without copying the file, the command line is changed as follows: xcopy \ awdata \ eports /d:12-29-2011 /l > After xcopy.out is executed, all files to be copied are listed in the file Xcopy.out. It is very important to back up files on the system and hidden files on a disk that contain system and implicit attributes. Generally, we are not allowed to delete or modify them at will. However, certain viruses or malicious programs tend to change or delete them, causing the system or program to be “critical”. In order to recover some or some of these files in a critical situation, it is necessary to back up these files (such as backing up to a directory in the mobile hard disk I: HideBak). So how do you implement a fast backup? Suppose we want to back up the files of all the system and hidden file attributes in the C drive. Use the above method to build a batch program COPYHIDE.BAT through Notepad. The details are as follows (Figure 5): XCOPY C:\\*.* /S /HI: The parameter /H in the \\HideBak command line indicates that files with hidden and system file attributes are copied. By default, the XCOPY command does not copy hidden or system files. Here we use a special case of this command. List of files that generate multiple partitions at a time. If there is a large amount of work data stored in the D, E, and F hard disk partitions of an employee's office computer, the employee often works overtime at home, and often needs to know whether there is a file name file in the office computer. It is necessary to have a list of information on the D, E and F disks of the office computer. So how do you quickly generate such a list? Just use the above method to create a small batch program and double-click to execute, you can get a manifest file LIST.TXT. The contents of the batch file are as follows (Figure 6): DIR D:\\*.* /B/SE:\\*.* /B/SF:\\*.* /B/S > LIST.TXT command line D:\\ *.* /B/S means E:\\*.* /B/S and F:\\*.* /B/S The three groups of parameters are separated by spaces. The last >gt.LIST.TXT indicates the previous display. The output path of the list is changed from the screen display to the file LIST.TXT output. In this way, we only need to copy the list file LIST.TXT to the computer in the home, and use the Notepad combined with the F3 function key to query the file names in the three partitions of the office computer with keywords. This article comes from [System Home] www.xp85.com
Copyright © Windows knowledge All Rights Reserved