locked
Script to create folders based on variable filename RRS feed

  • General discussion

  • Hi  I need to create folders(if not exist)  based on files names  and move that files to created folder .

    folder where files located: C:/metadata/calldata/

    filnames

    agentdata-121220171633.txt
    agentdata-121220171534.txt
    agentdata-121220171835.txt
    callesnotresponse-121220170812.txt
    callesnotresponse-121220171612.txt
    callesnotresponse-121220171812.txt
    calldetail-121220171845.txt
    calldetail-121220171745.txt
    calldetail-121220172040.txt
    calldetail-121220172141.txt


    Text files name has variable  length name files. I need to create folders based on filename(agentdata,callesnotresponse,calldetail) if not exist. then move files to corresponding folders.  

    1. get a loop
    2. put name into varible.
    3. find"-" possition number.
    4. subtract 1
    5. get the name
    6.check folder availabity based on the name.
    7.if exit just move text files, if not ,then  create folder as filename+(extra folders Badfile, Archived) and move text files.

    8. finally folders should be looks like
    C:/metadata/calldata/agentdata
    C:/metadata/calldata/agentdata/badfile
    C:/metadata/calldata/agentdata/Archive

    C:/metadata/calldata/callesnotresponse
    C:/metadata/calldata/callesnotresponse/badfile
    C:/metadata/calldata/callesnotresponse/Archive

    C:/metadata/calldata/calldetail
    C:/metadata/calldata/calldetail/badfile
    C:/metadata/calldata/calldetail/Archive


    Its bit hard me to how powershell can work for this. any one has an idea. Thanks heaps!!!!

    thanks

     

    Wednesday, December 13, 2017 8:18 PM

All replies