All Images in Folder...
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
All Images in Folder...
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
What is the best way for all systems
• By the name suffix ?
• By shell script ?
• Other ?
Thank for help
Jean-Marc
-
- VIP Livecode Opensource Backer
- Posts: 4002
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Jean-Marc,
I use something like this: 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
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
regards
Bernd
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
All Images in Folder...
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
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
-
- VIP Livecode Opensource Backer
- Posts: 4002
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
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.
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
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
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
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
All Images in Folder...
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
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
-
- VIP Livecode Opensource Backer
- Posts: 4002
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
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
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
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
All Images in Folder...
Bernd,
Thank for your help
I do a project and i will tell you when it is useful
Best regards
Jean-Marc
Thank for your help
I do a project and i will tell you when it is useful
Best regards
Jean-Marc