Newbie: How to manage the number of files in a folder
I have a backup application that runs each day and creates a file in a folder.
I have an iCal scipt which automates this backup to run at a specific time but I would like to modify it so that it deletes the oldest file in the folder. I cannot figure out the best way to do this. Does anyone have any suggestions?
This rather long script finds the oldest file in the complete nested range of a chosen outer folder and deletes it.
property filePathList : {}
property fileDateList : {}
getEveryFileName((choose folder) as alias)
Sort_items(fileDateList, filePathList)
set oldest to item 1 of filePathList
tell application "Finder" to delete oldest
to getEveryFileName(theFolder)
tell application "Finder"
my getNamesDates(get files of theFolder)
set FolderList to folders of theFolder
repeat with everyFolder in FolderList
my getEveryFileName(everyFolder)
end repeat
end tell
end getEveryFileName
to getNamesDates(FileList)
repeat with everyFile in FileList
try
tell application "Finder"
set end of fileDateList to modification date of everyFile
set end of filePathList to everyFile as alias
end tell
on error anError
display dialog anError
end try
end repeat
end getNamesDates
to Sort_items(sortList, SecondList)
-- sorts by the first list (dates), while keeping the second list in the same order.
tell (count sortList) to repeat with i from (it - 1) to 1 by -1
set s to sortList's item i
set r to SecondList's item i
repeat with i from (i + 1) to it
tell sortList's item i to if s > it then
set sortList's item (i - 1) to it
set SecondList's item (i - 1) to SecondList's item i
else
set sortList's item (i - 1) to s
set SecondList's item (i - 1) to r
exit repeat
end if
end repeat
if it is i and s > sortList's end then
set sortList's item it to s
set SecondList's item it to r
end if
end repeat
end Sort_items
dual-core G5/2.3 Mac OS X (10.4.6) dual screens
Similar Messages
-
How to get the number of files currently open?
hi,
does any one know how to get the number of files currently open in windows OS?
e.g. lets say .txt files...
any comment will be really appreciated.
thanksAssuming that you don't want to actually do this from within Java code (which would obviously require native code), here's a utility that will give you a list of which file handles are opened by which processes (on Windows):
http://www.sysinternals.com/ntw2k/freeware/handle.shtml
- K -
Hi all,
Can any one tell how to get the number of files(.EPS) count inside a folder when the folder path is specified in VC++ 6.0?
Thanks in Advance.
Regards
myriazI'm a little confused by the question, but it sounds like you're asking how to count the number of files with a particular extension in a given directory? That's not really an AI SDK question, but it's a fairly easy one to find if you google it. If you're trying to use Illustrator to do it, AI doesn't have a general purpose file API. It has a few functions to do some things that Illustrator needs, but I don't think enumerating directories is one of them.
-
How to increase the number of files picked up by File adaptor
Dear all,
Can any one tell me how to increase the number of files picked up by File adapter.
Pl post ASAP.
Useful answers will be appreciated accordingly.
Thanks,
SrinivasHi Srinivasa,
there is no parameter for number of files to be picked..............if you have too many source files and you want to get them processed quickly, then you can specify a very small polling interval, then XI will pick your source files quickly..........but it will cause heavy load on the XI system which can lead to blockage of messages in queues........
Regards,
Rajeev Gupta -
How to find the number of files in an oracle directory through a storedproc
hi
i have an oracle directory or a directory in an ftp server
is there any way.......through which..
i can know the number of files in the directory ...?
and whats the metadatacolumn that will indicate the name of the file?
and is it possible to loop through each of the entries within oracle
regards
rajops$tkyte@8i> GRANT JAVAUSERPRIV to ops$tkyte
2 /
Grant succeeded.
That grant must be given to the owner of the procedure.. Allows them to read
directories.
ops$tkyte@8i> create global temporary table DIR_LIST
2 ( filename varchar2(255) )
3 on commit delete rows
4 /
Table created.
ops$tkyte@8i> create or replace
2 and compile java source named "DirList"
3 as
4 import java.io.*;
5 import java.sql.*;
6
7 public class DirList
8 {
9 public static void getList(String directory)
10 throws SQLException
11 {
12 File path = new File( directory );
13 String[] list = path.list();
14 String element;
15
16 for(int i = 0; i < list.length; i++)
17 {
18 element = list;
19 #sql { INSERT INTO DIR_LIST (FILENAME)
20 VALUES (:element) };
21 }
22 }
23
24 }
25 /
Java created.
ops$tkyte@8i>
ops$tkyte@8i> create or replace
2 procedure get_dir_list( p_directory in varchar2 )
3 as language java
4 name 'DirList.getList( java.lang.String )';
5 /
Procedure created.
ops$tkyte@8i>
ops$tkyte@8i> exec get_dir_list( '/tmp' );
PL/SQL procedure successfully completed.
ops$tkyte@8i> select * from dir_list where rownum < 5;
FILENAME
data.dat
.rpc_door
.pcmcia
ps_data
http://asktom.oracle.com/pls/asktom/f?p=100:11:4403621974400865::::P11_QUESTION_ID:439619916584
Edited by: Salim Chelabi on 2009-04-21 10:37 -
Where to find the number of files in a folder (in Finder)?
I just upgraded from Snow Leopard.
In the past I could look at the bottom of the finder window and see how many files where in a particular folder. And how much megawattage they respresented in total.
Is there some kind of preference I can set in Mountain Lion to be able to see the 'number' of files in a given folder?
All ears,
BenThank you Kurt,
You're an ace.
Much appreciated.
Ben -
Programatically count the number of files in a folder
Hi Folks
I need to programatically count the number of files in a given folder and return the value to a Program Unit to be included in further processing.
Can anyone point me in the right direction. I have looked at UTL_FILE but this does not offer what I want.
Does anyone know of an obscure package in Oracle that I could use?
I'm using 9i in a W2K environment.
Many thanks
Simon GaddHi,
following a java based solution i found somewhere on Tom Kyte's AskTom forum.
GRANT JAVAUSERPRIV to TESTUSER;
dbms_java.grant_permission( 'TESTUSER', 'SYS:java.io.FilePermission', 'c:\', 'read' );
create global temporary table DIR_LIST
( filename varchar2(255) )
on commit delete rows
create or replace and compile java source named "DirList"
as
import java.io.*;
import java.sql.*;
public class DirList
public static void getList(String directory)
throws SQLException
File path = new File( directory );
String[] list = path.list();
String element;
for(int i = 0; i < list.length; i++)
element = list;
#sql { INSERT INTO DIR_LIST (FILENAME)
VALUES (:element) };
create or replace procedure get_dir_list( p_directory in varchar2 )
as language java
name 'DirList.getList( java.lang.String )';
exec get_dir_list( 'c:\temp' );
select count(*) from dir_list; -
How to count the number of files read through sender file adapter
Hi ,
I have a scenario where I am reading files from a third party system and trying to send those files to R/3 system .The frequency is 1 file per day .But there can be situation where the source system can put 2 to 3 files in source folder and so XI sender adapter will pick up all the 3 files at time . And I want to send only 1 file at a time to r/3 .
Do you know any way to handle this requirement ?
Thanks ,
SuvarnaHi,
Like Bhavesh pointed out, you could EOIO as the Quality of Servie in the sender file adapter.
But I guess this would solve your issue only to a certain extent.
Marking this QOS in the sender file adapter would only mean sequential processing of the files. That is, the second file will be sent only when the first file is successfully received by the end system.
It would not ensure that the files are sent only after 15 mins of the first file is sent.
If the 15 mins time period is important, then this needs to be achieved using a BPM which ensures that the messages are sent to the target only every 15 mins.
In case, the frequency of the incoming files is not known (in which case, the having a BPM would be a bad idea) you could use a ztable, which stores the filename and time the file was sent to the R/3.
You could query this table each time, before sending the file data to the R/3
Regards,
Smitha.
Message was edited by:
Smitha Rao -
Displaying the number of files in a folder with Mountain Lion?
I recently purchased a new iMac with Mountain Lion and I pretty much hate it. I have been a fan of just about EVERY update, so I am not resistant to change. I just think this is an inferior product. It is slow, clunky, and the update alerts remind me of everything that I hated about PCs. Meh.
Anyway, one of the main problems I have with it is that in previous versions, when I opened a folder, there was a little bit of information at the bottom of the folder that told me how many files were in that folder. As a photographer, I use this information ALL THE TIME. I realize I can click on the folder and "get info" to see how many files are in it...but this is extremely inefficient (especially considering how slow the brand new system is -- in spite of the 3.4 Hz processor and 16GB of RAM).
I can't seem to find anything in the preferences that allows me to change this. If there is a way, I would greatly appreciate it if someone would tell me how! Thank you!Active Memory: 1.88 GB
Free Memory: 91.6 MB
Wired Memory: 1.33 GB
Used Memory: 15.90 GB
Inactive Memory: 12.69 GB
Total VM: 232.58 GB
Number of processes: 92
PID Process Name User CPU Real Mem Virtual Mem
0 kernel_task root 1.6 893.4 MB 10.17 GB
1 launchd root 0.0 2.3 MB 2.39 GB
11 UserEventAgent root 0.0 4.6 MB 2.41 GB
12 kextd root 0.0 6.7 MB 2.39 GB
14 notifyd root 0.0 1.8 MB 2.40 GB
15 securityd root 0.0 10.2 MB 2.41 GB
16 diskarbitrationd root 0.0 2.3 MB 2.39 GB
17 powerd root 0.0 2.4 MB 2.41 GB
18 configd root 0.0 4.9 MB 2.39 GB
19 syslogd root 0.0 1.5 MB 2.40 GB
20 cfprefsd root 0.0 1.8 MB 2.39 GB
21 distnoted root 0.0 2.3 MB 2.41 GB
22 opendirectoryd root 0.0 11.8 MB 2.43 GB
30 warmd nobody 0.0 6.1 MB 2.39 GB
31 usbmuxd _usbmuxd 0.0 2.5 MB 2.40 GB
34 stackshot root 0.0 1.4 MB 2.39 GB
37 revisiond root 0.0 3.0 MB 2.41 GB
38 ptmd root 0.0 1.7 MB 2.38 GB
42 mds root 0.0 127.6 MB 2.93 GB
43 mDNSResponder _mdnsrespo 0.0 3.9 MB 2.40 GB
46 loginwindow karibedfor 0.0 22.0 MB 2.49 GB
47 locationd _locationd 0.0 7.9 MB 2.41 GB
48 KernelEventAgent root 0.0 1.1 MB 2.37 GB
50 hidd root 0.6 3.2 MB 2.39 GB
51 fseventsd root 0.0 15.5 MB 2.42 GB
53 dynamic_pager root 0.0 808 KB 2.32 GB
55 dpd root 0.0 1.9 MB 2.38 GB
56 appleeventsd _eppc 0.0 3.2 MB 2.41 GB
59 blued root 0.0 4.6 MB 2.41 GB
61 autofsd root 0.0 2.1 MB 2.39 GB
62 apsd root 0.0 9.6 MB 2.41 GB
63 coreservicesd root 0.0 24.8 MB 2.43 GB
66 WindowServer _windowser 2.7 52.1 MB 2.97 GB
74 netbiosd _netbios 0.0 3.3 MB 2.40 GB
75 CVMServer root 0.0 1.9 MB 2.41 GB
91 networkd _networkd 0.0 1.4 MB 2.39 GB
100 aosnotifyd root 0.0 8.5 MB 2.41 GB
113 logind root 0.0 2.0 MB 2.39 GB
114 coreaudiod _coreaudio 2.2 9.3 MB 2.40 GB
120 launchd karibedfor 0.0 1.6 MB 2.39 GB
123 UserEventAgent karibedfor 0.0 10.1 MB 2.41 GB
124 distnoted karibedfor 0.0 3.6 MB 2.41 GB
126 cfprefsd karibedfor 0.0 2.3 MB 2.39 GB
132 pboard karibedfor 0.0 996 KB 2.32 GB
137 usernoted karibedfor 0.0 4.4 MB 2.41 GB
141 talagent karibedfor 0.0 7.9 MB 2.43 GB
142 Dock karibedfor 0.0 31.0 MB 2.47 GB
143 SystemUIServer karibedfor 0.0 23.3 MB 2.50 GB
144 Finder karibedfor 0.0 127.3 MB 2.66 GB
154 filecoordinationd root 0.0 12.5 MB 2.39 GB
159 Notification Center karibedfor 0.0 15.3 MB 2.46 GB
162 imagent karibedfor 0.0 6.6 MB 2.41 GB
169 AirPort Base Station Agen karibedfor 0.0 2.0 MB 2.38 GB
172 NetworkBrowserAgent karibedfor 0.0 7.7 MB 2.41 GB
178 fontd karibedfor 0.0 5.8 MB 2.44 GB
181 Photo Stream karibedfor 0.0 17.0 MB 2.44 GB
186 com.apple.dock.extra karibedfor 0.0 18.1 MB 2.44 GB
187 lsboxd karibedfor 0.0 4.3 MB 2.41 GB
189 launchd _spotlight 0.0 1.0 MB 2.39 GB
192 distnoted _spotlight 0.0 1.9 MB 2.41 GB
216 AppleSpell.service karibedfor 0.0 17.0 MB 2.44 GB
243 ntpd root 0.0 1.3 MB 2.32 GB
525 syspolicyd root 0.0 7.5 MB 2.39 GB
569 Photo Mechanic karibedfor 0.5 535.1 MB 1.33 GB
1047 storeagent karibedfor 0.0 12.2 MB 2.42 GB
1061 maspushagent karibedfor 0.0 5.5 MB 2.40 GB
2094 SleepServicesD root 0.0 1.6 MB 2.34 GB
2118 cfprefsd _spotlight 0.0 1.4 MB 2.39 GB
2139 taskgated root 0.0 3.8 MB 2.40 GB
2156 cookied karibedfor 0.0 1.6 MB 2.39 GB
2176 Safari karibedfor 0.0 63.7 MB 3.57 GB
2181 xpcd karibedfor 0.0 6.6 MB 2.41 GB
2185 com.apple.iCloudHelper karibedfor 0.0 6.2 MB 2.41 GB
2283 pbs karibedfor 0.0 6.9 MB 2.40 GB
2333 ocspd root 0.0 2.8 MB 2.37 GB
2347 accountsd karibedfor 0.0 5.2 MB 2.37 GB
2355 xpcd _spotlight 0.0 4.8 MB 2.36 GB
2370 mdworker karibedfor 0.0 10.2 MB 2.38 GB
2373 CalendarAgent karibedfor 0.0 14.8 MB 2.41 GB
2374 tccd karibedfor 0.0 2.0 MB 2.36 GB
2376 Safari Web Content karibedfor 0.3 207.2 MB 3.76 GB
2383 syncdefaultsd karibedfor 0.0 12.4 MB 2.41 GB
2386 mdworker karibedfor 0.0 8.3 MB 2.37 GB
2387 Flash Player (Safari Inte karibedfor 0.9 48.4 MB 3.56 GB
2388 helpd karibedfor 0.0 2.2 MB 2.37 GB
2389 Activity Monitor karibedfor 4.1 23.3 MB 2.49 GB
2391 activitymonitord root 1.0 1.4 MB 2.33 GB
2392 CVMCompiler karibedfor 0.0 20.3 MB 2.38 GB
2393 mdworker _spotlight 0.0 5.7 MB 2.36 GB
2394 mdworker _spotlight 0.0 10.3 MB 2.40 GB
2395 mdworker karibedfor 0.0 9.4 MB 2.40 GB
2396 sandboxd root 0.0 6.7 MB 2.41 GB -
How to change the default "Safe" files in Safari?
I would really appreciate if anybody could teach me how to change the default "Safe" files using AppleScripts, Folder Actions or .plist files. I really would like to have some files to open automatically after download, specially .pps files, and safari doesn't recognize such files as "safe". I tried to find out reading the help files but got lost.
I posted a reply in an old topic for somebody who seemed to know, but it was not related to that topic, so I decided to open a new one.
I'll be gratefull for any help. Thanks.Hi MDRC,
Have a read of [this topic|http://discussions.apple.com/thread.jspa?threadID=1237961] to see if that helps. -
How to check the number of colors in the file???
How to check the number of colors in the file ai ???
The Recolor Artwork tool will list all colors used in a document and the flyout menu in the Swatches panel also provides tools for managing colors.
Mylenium -
How to find the number of data items in a file written with ArryToFile function?
I have written an array of number in 2 column groups to a file using the LabWindows/CVI function ArrayToFile...Now if I want to read the file with FileToArray Function then how do I know the number of items in the file. during the write time I know how many array items to write. but suppose I want the file to read at some later time then How to find the number of items in the file,So that I can read the exact number and present it. Thanks to all
If you are young work to Learn, not to earn.
Solved!
Go to Solution.What about:
OpenFile ( your file );
cnt = 0;
while ((br = ReadLine ( ... )) != -2) {
if (br == -1) {
// I/O error: handle it!
break;
cnt++;
CloseFile ( ... );
There are some ways to improve performance of this code, but if you are not reading thousands of lines it's quite fast.
After this part you can dimension the array to pass to FileToArray... unless you want to read it yourself since you already have it open!
Proud to use LW/CVI from 3.1 on.
My contributions to the Developer Zone Community
If I have helped you, why not giving me a kudos? -
How to manage the files in Ipod?
Hi everybody!
I just bought a 80GB Ipod and I'm having a hard time figuring it out how to manage the files I've downloaded to it. I just sent a podcast to it but it doesn't appear it the Podcast folder. I have to search it in the entire list of files. Can someone tell me how I can manage these files?
Thank you very much!Hi everybody!
I just bought a 80GB Ipod and I'm having a hard time
figuring it out how to manage the files I've
downloaded to it. I just sent a podcast to it but it
doesn't appear it the Podcast folder. I have to
search it in the entire list of files. Can someone
tell me how I can manage these files?
Thank you very much!
Use iTunes. -
How to find the number of links in a website
hi every body
can any one clear my doubt
my doubt is that
in a website how to find the number of links the hole website contains
is there any navigation tool to find that
plz help me yar
i am waiting for the replyIf you're talking about commercial sites (sites you don't have the source code for) I'm not sure.
If you want to count the links in site that you have the source code for, it should be relatively easy to write a Java application to do it. All you really need to do is have a list of the files you want to count links in, read each file line by line and check for the existance of the <a> tag in each line. Anywhere their is an <a> tag there is a link.
Hope this helps. -
How to find the number of ODBC connections to Oracle Database
Hi All,
How to find the number of ODBC connections and all connections to the Database in last week. Are there any views to get this information?
Thanks in advance,
MahiWhat Ed said is true that Oracle doesn't note which type of protocol is connecting to the database, however, you can see which program is accessing the database.
For example: if you already know of a user using ODBC, you can verify as:
select username, osuser, terminal, program from v$session where username = 'SCOTT'
USERNAME OSUSER TERMINAL PROGRAM
SCOTT IUSR_SRV231 SRV231 w3wp.exe
SCOTT IUSR_SRV231 SRV231 w3wp.exe
2 rows selected.Assuming that you can confirm the progam noted in the above (example) is the one using ODBC, then you can change the query such as:
SQL> select username, osuser, terminal, program from v$session where program = 'w3wp.exe';
USERNAME OSUSER TERMINAL PROGRAM
SCOTT IUSR_SRV231 SRV231 w3wp.exe
SCOTT IUSR_SRV231 SRV231 w3wp.exe
2 rows selected.Just for kicks, I checked our listener.log file, but there was no reference of odbc in it either.
Hope this helps...
Maybe you are looking for
-
Cluster Installation Error while running root.sh
Hi all, Please help I tried to install clusterware but when i run root.sh on first node it shows as below [root@rac11g1 etc]# /u01/app/oraInventory/orainstRoot.sh Changing permissions of /u01/app/oraInventory to 770. Changing groupname of /u01/app/or
-
Test Scripts for Process Chains
Hi Gurus, Can anybody send me the sample test scripts or the available links for process chains to my mail Id. [email protected] I will assign full points. Thanks in adance. Maruthi.
-
I have to export out a series of movies from Premiere CS6 (Windows 7) to an H264 movie (.mov) ... that I can pull into a Mac, so as to be able to use my Mac setup and DVKitchen to prep the movies for Vimeo et. al. From Premiere I've output an H264 fi
-
HTML Link -AS2 fine, AS3 weird behaviour
Hi Guys, I'm working on a project at the moment, and am seeing weird behaviour with the way my swf handles html links inside dynamic textboxes. When rendered as a AS2 file, the link works on a release as expected. When its inside a AS3 file the link
-
What programming language is used to create applicaitons for the iPad
I was curious what programming language is used to create applications for the iPad.