Announcement

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

  • Renaming photos using renfiles

    Hello stata users!

    I'm trying to rename all my photos from something like 1295294 to names that contain location and a number. For example, Mexico_photo1.

    Here's my code:

    forval x = 1/`c(N)' {



    local oldname = img_name_[`x']
    local newname = new_name_[`x']
    di "`oldname'"
    di "`newname'"

    renfiles, insign("`oldname'") outsign("`newname'") erase

    }


    The two variables described above are: img_name_, which contains photo numbers like 12345, 13456, 16578, and new_name_, which contains my desired photo names such as Mexico_photo1, UK_photo1. My goal is to assign names to all photos, but the issue is that I also want to assign similar names to certain photo numbers. For example, I want both photo 12345 and photo 18739 to have the name Mexico_photo1. However, my current code is unable to assign the same names to different photos. I would greatly appreciate any suggestions on how to modify my code to achieve this purpose. Thank you in advance for your help.

  • #2
    Well, your operating system will prevent two files from having the same name and being in the same folder. Each file on the computer must have a unique fully specified path. One option might be to make sure files with the same name are in different folders.

    Comment

    Working...
    X