Page 1 of 1
All Images in Folder...
Posted: Sat May 09, 2009 3:24 pm
by jmburnod
I want check the files image (jpg,png,bmp) in a folder
What is the best way for all systems
• By the name suffix ?
• By shell script ?
• Other ?
Thank for help
Jean-Marc
Posted: Sat May 09, 2009 5:54 pm
by bn
Jean-Marc,
I do it with the suffix. It works on MacOS X and Windows, dont know about Linux.
I dont use the shell for this, Rev has in my opinion enough built-in options.
regards
Bernd
Posted: Sat May 09, 2009 6:15 pm
by bn
Jean-Marc,
I use something like this:
Code: Select all
on mouseUp
answer folder "please choose folder"
if it is empty then exit mouseUp
put the defaultfolder into oldDefault
-- necessary for "put the files into" to work
put it & "/" into tmyPath
set the defaultfolder to it
put the files into tAllFiles
set the defaultfolder to oldDefault -- just to be nice
put "" into tmyResultingFiles
put "*.png,*.bmp,*.jpg" into mySuffixes
repeat for each item aSuffix in mySuffixes
put tAllfiles into tFilesToFilter
filter tFilesToFilter with aSuffix
put tFilesToFilter after tmyResultingFiles
end repeat
-- the names of the files
put tmyResultingFiles
-- now the path and name of file
repeat with i = 1 to the number of lines of tmyResultingFiles
put tmyPath & line i of tmyResultingFiles into line i of tmyResultingFiles
end repeat
put tmyResultingFiles after msg
end mouseUp
note that I dont know how to make a clever regular expression to filter in one command. So I do it the poor mans way in a repeat loop.
regards
Bernd
All Images in Folder...
Posted: Sun May 10, 2009 10:46 am
by jmburnod
Guten Tag Bernd,
Und vielen dank für deine hilfe
I tested your script and it return stranges results
(I work with RevStudio 2.9 on a powerbook with 10.4.2)
You can see my comments there begin with "--••JMB"
I will test it with RevStudio 3.0
Best regards
Jean-Marc
Code: Select all
on mouseUp
answer folder "please choose folder"
if it is empty then exit mouseUp
put the defaultfolder into oldDefault
-- necessary for "put the files into" to work
put it & "/" into tmyPath
set the defaultfolder to it
--••JMB the defaultfolder contains 15 files and one png, one bmp and one jpg
put the files into tAllFiles
set the defaultfolder to oldDefault -- just to be nice
put "" into tmyResultingFiles
put "*.png,*.bmp,*.jpg" into mySuffixes
repeat for each item aSuffix in mySuffixes
put tAllfiles into tFilesToFilter
filter tFilesToFilter with aSuffix
put tFilesToFilter after tmyResultingFiles
end repeat
--••JMB the num of lines of tmyResultingFiles = 1 the three files (png,bmp,lpg) are on the same line
--••JMB like that "jhm05.pngImage 2.bmpImage 3.jpg"
-- the names of the files
put tmyResultingFiles --••JMB the num of lines of tmyResultingFiles = 1
-- now the path and name of file
repeat with i = 1 to the number of lines of tmyResultingFiles
put tmyPath & line i of tmyResultingFiles into line i of tmyResultingFiles
end repeat
put tmyResultingFiles after msg
--••JMB tmyResultingFiles = "/Users/p3sr/Desktop/DesFiImages/jhm05.pngImage 2.bmpImage 3.jpg"
end mouseUp
Posted: Sun May 10, 2009 11:33 am
by bn
Jean-Marc,
touché...
I did not test for just one file of each type in a folder. As you noticed right away it does not work correctly.
Here is a corrected version. I direct the output to a field 1 and with pathes to field 2, you might adjust your teststack.
Code: Select all
on mouseUp
answer folder "please choose folder"
if it is empty then exit mouseUp
put the defaultfolder into oldDefault
-- necessary for "put the files into" to work
put it & "/" into tmyPath
set the defaultfolder to it
put the files into tAllFiles
set the defaultfolder to oldDefault -- just to be nice
put "" into tmyResultingFiles
put "*.png,*.bmp,*.jpg" into mySuffixes
repeat for each item aSuffix in mySuffixes
put tAllfiles into tFilesToFilter
filter tFilesToFilter with aSuffix
if tFilesToFilter is not "" then
put tFilesToFilter & return after tmyResultingFiles
end if
end repeat
if last char of tmyResultingFiles = cr then delete char -1 of tmyResultingFiles
-- the names of the files
put tmyResultingFiles into field 1
-- now the path and name of file
repeat with i = 1 to the number of lines of tmyResultingFiles
put tmyPath & line i of tmyResultingFiles into line i of tmyResultingFiles
end repeat
put tmyResultingFiles into field 2
end mouseUp
again please make shure it produces the results you want.
btw: I used to live for one year in Lausanne, so we were almost neighbors
Wonderful lake geneva. right across from Evian, and my room overlooked the lake and at night I saw the lights of Evian. Also la corniche and so on. I still have very fond memories.
regards
edit:
et salut
Bernd
All Images in Folder...
Posted: Sun May 10, 2009 4:35 pm
by jmburnod
Vielen dank noch einmal Bernd,
It work now and i test the same for sound files
What do you think about the list of suffixs for sounds ?
(for window,mac and linux)
All the best
Jean-Marc
Posted: Sun May 10, 2009 8:51 pm
by bn
Jean-Marc,
there are so many different suffixes for sound that I dont know what to say. I am not an expert in sound files anyway. If you are on a mac then you can look up the many suffixes supported by Quicktime in the System preferences->Quicktime->avancé->Réglages Mime. There you find the suffixes for sound files if you click on mp3 for example then in the box right above Valeurs par défaut you will find four Extensions mp3 and so on. I imagine if you have Quicktime for Windows there will be something similar.
It all depends what you want to do with the files and whether the user has the codecs for these files.
So my answer would be: it depends.....
salut
Bernd
All Images in Folder...
Posted: Tue May 12, 2009 6:42 pm
by jmburnod
Bernd,
Thank for your help
I do a project and i will tell you when it is useful
Best regards
Jean-Marc