用于复制和粘贴文件的脚本

时间:2017-03-22 21:30:45

标签: batch-file

我正在尝试完成几百个文件的复制,并将包含许多目录的源文件复制到一个新文件中。我有一个带有文件名及其路径的电子表格,因此我将该列表连接到一个名为:file-list.txt的文本文件中。我希望脚本在S /驱动器中搜索文本文件中提供的文件路径,然后将其复制到目标文件夹

我在下面找到了这个脚本,但我不能让它符合我的目的:

echo off
set src_folder=S:\data\010\Files
set dst_folder=C:\Users\Desktop\test
for(/f "tokens=*" %%i in file-list.txt do (
    xcopy /s/e/u "%src_foler%\%%i" "dest_folder%"))

file-list.txt中的文件示例是:

\leaserecords1\SL0000NQ\LD00GN21.pdf
\leaserecords1\SL0000NZ\LD00I4QX.pdf
\leaserecords1\SL00001F\LD003CQ9.TIF

1 个答案:

答案 0 :(得分:0)

根据您提供的脚本进行假设。

def averageWordLength(myString):
    char = ""
    punctuation = [" ", "!", "?", ".", ","]
    letters = 0
    words = 0
    if not myString == str(myString):
        return "Not a string"
    try:
        for i in myString:
            if i not in punctuation:
                letters += 1
            elif i in punctuation:
                if char not in punctuation:
                    words += 1
                elif char in punctuation:
                    pass
            char = i

        if letters == 0:
            return "No words"
        else:
            average = letters / (words + 1)
            return letters, words + 1, average
    except TypeError:
        return "No words"
print(averageWordLength("Hi"))
print(averageWordLength("Hi, Lucy"))
print(averageWordLength("   What   big spaces  you    have!"))
print(averageWordLength(True))
print(averageWordLength("?!?!?! ... !"))
print(averageWordLength("One space. Two spaces.  Three spaces.   Nine spaces.         "))