Wild Path Origin PowerShell file operation practical function MSSQL123

Source: Internet
Author: User

Due to work needs, processing a batch of documents, this would like to write C # to deal with, and then think of this is the bounden duty of PowerShell, simply on-line various search, all kinds of demo, all kinds of changes, spent half a day, and finally put together to achieve the effect.   PowerShell is not familiar with itself, there may be some detours, the implementation of the more rotten, in short, a variety of small functions pieced together, and finally pieced together to achieve the effect. The following is the original demo, relatively naïve, right when it is their own records of notes 1, File information statistics below the folder has six text files, statistics This folder below the file name to a log file

The file information under this folder is counted, there is a file with a specified path, the file is generated according to the time.

The following is the generated statistics file information

If you want to count the full path of the file, use FullName directly, $fileName = $file. FullName can get the full path of the file.

If you want to facilitate the contents of all the files and subfolders under the folder under a certain path, you can add the-recurse parameter, that is: $files = Get-childitem "F:\TestPowerShell"-recurse

This is the result of the record.

If you want to count a certain type of file, you need to add the-include *.txt parameter to specify the suffix name, namely: $files = Get-childitem "F:\TestPowerShell"-recurse-include *.txt 2, file operations (copy) such as the creation of folders and subfolders copied to another path, here a new folder, with the date and time named

After running the script, copy the files and subfolders under the specified folder to another directory.

If you want to copy all the files (including subfolders) under one path (or multiple paths) to a folder, you can conveniently copy files to the target folder in a single file ($file in $fileList more information:/HTTP www.wangzhanjianshegs.com/

Wild Path Origin PowerShell file operation practical function MSSQL123

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.