Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Paula de Souza Leao Spinola
    started a topic Deleting a folder

    Deleting a folder

    Is there a way to remove a folder?
    Actually, in my do file I would like to zip a folder and delete the unzipped one.

    Somthing like below. The second command do not work because Arquivos_dbf is a folder, nor a file. -rmdir- do not work either.
    Code:
    zipfile Arquivos_dbf, saving(Arquivos_dbf, replace)
    erase Arquivos_dbf

  • James Voss
    replied
    I think the title of this thread is not clear enough for my issue, so I am creating a new thread for this.
    The new location of the post is here: https://www.statalist.org/forums/for...-s#post1730033
    Last edited by James Voss; 12 Oct 2023, 13:05.

    Leave a comment:


  • James Voss
    replied
    Hello all,
    This is a related question. I'm trying to empty out all of the files from a folder before populating the same folder with new files (the files are created as part of a foreach loop). Historically, I've done this by deleting the folder using -rmdir- and then recreating the folder by using -mkdir- .

    Sometime in the past two weeks, the -rmdir- has stopped working. When I run this code:


    !rmdir "D:\MyDocs\StataUserFiles\Projects\BPAinSTATA\ do_f ile_stages\Stage5\DTAfiles" /s /q


    STATA produces the following comments:

    Remove-Item : A positional parameter cannot be found that accepts argument '/s'.
    At line:1 char:1
    + rmdir D:\MyDocs\StataUserFiles\Projects\BPAinSTATA\do_fi le_stages\Sta ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: ( [Remove-Item], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.C ommands.RemoveItemCommand




    I am using version 18, but have also gone back and set the version to 17.0 and the same comments appear.
    I've checked the directory path several times, including copying and pasting the directory path to avoid typos. No help.
    I cannot find anything on "Remove-Item."

    I presume I'm missing something obvious.
    Any ideas?
    Thank you!

    Leave a comment:


  • Joro Kolev
    replied
    Dont you see your files in the Trash bin?

    I started using the MacBook Air 2 months ago, and I still have not figured out how to delete files without sending them to Trash first. I.e., it seems that in Mac there is no corresponding to the Shift + Del action on Windows.
    Originally posted by Joshua Weiss View Post
    Hi, I used the following command to delete one file on my MAC but deleted all the files on my desktop. Is there anybody who knows how to recover my deleted files? Please help!! Thanks
    Code:
    shell rm -r "The Folder"

    Leave a comment:


  • Joshua Weiss
    replied
    Hi, I used the following command to delete one file on my MAC but deleted all the files on my desktop. Is there anybody who knows how to recover my deleted files? Please help!! Thanks
    Code:
    shell rm -r "The Folder"

    Leave a comment:


  • Andrés Lahur Talavera Cuya
    replied
    Hi. Please ¿how to delete a file, inside a zipped file?
    I use windows

    Leave a comment:


  • Tomas Guanziroli
    replied
    It works! Thank you!

    Leave a comment:


  • Romalpa Akzo
    replied
    In Mac OS, try below command:
    Code:
    shell rm -r "The Folder"
    Also consider below line, which moves the folder to the Trash instead:
    Code:
    shell mv -f "The Folder" ~/.Trash

    Leave a comment:


  • Tomas Guanziroli
    replied
    Hi all,
    Following up on a similar problem. I am successfully using the code that Romalpa Akzo shared above to erase files from a dropbox folder on my Windows operating system.
    However, I cannot run the same line of code on my Mac.

    I get the following message:

    rmdir: "Folder": Directory not empty
    rmdir: /s: No such file or directory
    rmdir: /q: No such file or directory


    So somehow Stata (14) recognizes "/s" and "/q" as additional folders, and not commands.
    I already checked that the "Folder" is correct in both computers.

    Any suggestions/help?
    Thanks a lot






    Leave a comment:


  • Romalpa Akzo
    replied
    Below code would help.​​​​But caution should be paid to be sure about what you wanna delete.
    Code:
    shell rd "Folder" /s /q

    Leave a comment:


  • Paula de Souza Leao Spinola
    replied
    Many thanks Friedrich Huebler. When I run the code above, the attached blue window shows up. I should then manually enter "y" into the blue window. As I would like to delete folders throughout my code, would it be possible to make Stata delete the folder without showing the blue window or to write a line in the code in which "y" is entered in the blue window?
    Attached Files

    Leave a comment:


  • Friedrich Huebler
    replied
    Code:
    shell rmdir "myfolder" /s
    This deletes the folder and all files and folders in the folder.

    Leave a comment:


  • BOTI DAVID
    replied
    Hi
    i want to delete a folder which not empty
    so i excecute the comand line: shell rmdir "myfolder"
    but it does not work.
    can i have help on this?
    Sorry for my english, i hope it is understandable

    Leave a comment:


  • Richard Williams
    replied
    See if -help shell- will tell you how to do what you want.

    Leave a comment:

Working...
X