Debian Codegraph @

docs/manual/Create_Strings_as_file_list___.html

raw symbols SCIP
1 <html><head><meta name="robots" content="index,follow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
2 <title>Create Strings as file list...</title>
3 <style>
4 td { padding-left: 5pt; padding-right: 5pt; }
5 th { padding-left: 5pt; padding-right: 5pt; }
6 code { white-space: pre-wrap; }
7 dd { white-space: pre-wrap; }
8 </style>
9 </head><body bgcolor="#FFFFFF">
10
11 <table border=0 cellpadding=0 cellspacing=0><tr><td bgcolor="#CCCC00"><table border=4 cellpadding=9><tr><td align=middle bgcolor="#000000"><font face="Palatino,Times" size=6 color="#999900"><b>
12 Create Strings as file list...
13 </b></font></table></table>
14 <p>A command in the <a href="New_menu.html">New menu</a> to create a <a href="Strings.html">Strings</a> object containing a list of files in a given folder.</p>
15 <h2>Settings</h2>
16 <p align=middle><img height=244 width=540 src=Create_Strings_as_file_list____1.png></p><dl>
17 <dt><b>Name</b>
18 <dd>the name of the resulting Strings object.</dd>
19 <dt><b>File path</b>
20 <dd>the folder name, with optional <i>wildcards</i> (see below) for selecting files.</dd>
21 </dl>
22 <h2>Behaviour</h2>
23 <p>The resulting Strings object will contain an alphabetical list of file names (by na&#239;ve Unicode-sorting), without the preceding path through the folder structures. If there are no files that match the file path, the Strings object will contain no strings.</p>
24 <h2>Usage</h2>
25 <p>There are two ways to specify the file path.</p>
26 <p>One way is to specify a folder name only. On Unix, the file path could be <code><font size=+1>/usr/people/miep/sounds</font></code> or <code><font size=+1>/usr/people/miep/sounds/</font></code>, for instance. On Windows, <code><font size=+1>C:\Users\Miep\Sounds</font></code> or <code><font size=+1>C:\Users\Miep\Sounds\</font></code>. On Macintosh, <code><font size=+1>/Users/miep/Sounds</font></code> or <code><font size=+1>/Users/miep/Sounds/</font></code>. Any of these produce a list of all the files in the specified folder.</p>
27 <p>The other way is to specify a <i>wildcard</i> (an asterisk) for the file names. To get a list of all the files whose names start with &#8220;<code><font size=+1>hal</font></code>&#8221; and end in &#8220;<code><font size=+1>.wav</font></code>&#8221;, type <code><font size=+1>/usr/people/miep/sounds/hal*.wav</font></code>, <code><font size=+1>C:\Users\Miep\Sounds\hal*.wav</font></code>, or <code><font size=+1>/Users/miep/Sounds/hal*.wav</font></code>.</p>
28 <p>You can even use <i>two</i> wildcards: <code><font size=+1>/usr/people/miep/sounds/*al*.wav</font></code> gives you a list of all files whose names contain <code><font size=+1>al</font></code> and end in <code><font size=+1>wav</font></code>.</p>
29 <h2>Script usage</h2>
30 <p>In a script, you can use this command to cycle through the files in a folder. For instance, to read in all the sound files in a specified folder, you could use the following script:</p>
31 <code> folder$ = “/usr/people/miep/sounds”<br></code>
32 <code> strings = <b>Create Strings as file list:</b> “list”, folder$ + “/*.wav”<br></code>
33 <code> numberOfFiles = Get number of strings<br></code>
34 <code> for ifile to numberOfFiles<br></code>
35 <code> <a href="_selectObject_.html">selectObject</a>: strings<br></code>
36 <code> fileName$ = Get string: ifile<br></code>
37 <code> <a href="Read_from_file___.html">Read from file:</a> folder$ + “/” + fileName$<br></code>
38 <code> endfor<br></code>
39 <code> removeObject: strings<br></code>
40 <p>If the script has been saved to a script file, you can use file paths that are relative to the folder where you saved the script. Thus, with</p>
41 <code> <b>Create Strings as file list:</b> “list”, “*.wav”<br></code>
42 <p>you get a list of all the <code><font size=+1>.wav</font></code> files that are in the same folder as the script that contains this line. And to get a list of all the <code><font size=+1>.wav</font></code> files in the folder <code><font size=+1>Sounds</font></code> that resides in the same folder as your script, you can do</p>
43 <code> <b>Create Strings as file list:</b> “list”, “Sounds/*.wav”<br></code>
44 <p>As is usual in Praat scripting, the forward slash (&#8220;/&#8221;) in this example can be used on all platforms, including Windows. This makes your script portable across platforms.</p>
45 <p>Note that the above functionality can also be written four lines shorter, using built-in functions:</p>
46 <code> folder$ = “/usr/people/miep/sounds”<br></code>
47 <code> list$# = <b><a href="_fileNames-S-H_.html">fileNames$#</a></b>: folder$ + “/*.wav”<br></code>
48 <code> for ifile to <a href="_size_.html">size</a> (list$#)<br></code>
49 <code> <a href="Read_from_file___.html">Read from file:</a> folder$ + “/” + list$# [ifile]<br></code>
50 <code> endfor<br></code>
51 <p>This doesn&#8217;t produce a Strings object.</p>
52 <h2>See also</h2>
53 <p>To get a list of folders instead of files, use <a href="Create_Strings_as_folder_list___.html">Create Strings as folder list...</a>.</p>
54 <h3>Links to this page</h3>
55 <ul>
56 <li><a href="FAQ__Scripts.html">FAQ: Scripts</a>
57 <li><a href="What_was_new_in_3_8_.html">What was new in 3.8?</a>
58 <li><a href="What_was_new_in_4_5_.html">What was new in 4.5?</a>
59 <li><a href="What_was_new_in_4_6_.html">What was new in 4.6?</a>
60 <li><a href="What_was_new_in_5_4_.html">What was new in 5.4?</a>
61 <li><a href="What_s_new_.html">What's new?</a>
62 </ul>
63 <hr>
64 <address>
65 <p>© Paul Boersma 1998,2006,2013-2015,2020,2024,2025</p>
66 </address>
67 </body>
68 </html>