BookmarkSubscribeRSS Feed
Citrine10
Obsidian | Level 7

 Hi there,

I am busy cleaning up our backdated files where we have zipped the files to save storage space.

I am trying to create the code to scan through my various folders and if there are files that have been unzipped then it zips it if the zipped file doesn't exists, otherwise if the files have been unzipped and the zipped ones exists, then it should delete the original file. 

3 REPLIES 3
Quentin
Super User

It would be *possible* to do this with SAS, but probably better to use some sort of shell script.  If you're doing it with SAS, can you show the code you have tried, and describe where you're stuck?  If you're looking for examples of how to zip files using SAS, I would try searching lexjansen.com for user group papers.  This search string has plenty of hits:  https://www.google.com/search?q=site%3Alexjansen.com+zip+-%22zipcode%22 

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
Tom
Super User Tom
Super User

More details are required to give details.

What types of files are these?  

What type of "zip" files are you making?

If they are actually gzip files then it will be easier since a gzip file contains only one original file.  But at an actual zip file is an archive file format that can contain multiple files.  So figuring out whether a non zipped file exists in one of the existing zip archive files will be harder.

 

You will probably want to start be getting the list of files.  You could use this macro: https://github.com/sasutils/macros/blob/master/dirtree.sas

Which can be used to build a dataset with the names size and dates for all files in one (or more) directory trees.

ballardw
Super User

@Citrine10 wrote:

 Hi there,

I am busy cleaning up our backdated files where we have zipped the files to save storage space.

I am trying to create the code to scan through my various folders and if there are files that have been unzipped then it zips it if the zipped file doesn't exists, otherwise if the files have been unzipped and the zipped ones exists, then it should delete the original file. 


This sounds like a seriously dangerous potential cause of loss of data. So if there is one "Backup.zip" do you intend to delete every "backup.txt" "backup.xls" "backup.doc" "backup.bmp" "backup.png"?

I would say that if your process does not "unzip" and  verify the contents match the file you are considering deleting that it is a flawed process. Without a comparison, there is no guarantee that the zipped file has the latest version is there?

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 470 views
  • 1 like
  • 4 in conversation