Vidir: Difference between revisions

4,138 bytes added ,  3 months ago
m
→‎{{header|Wren}}: Changed to Wren S/H
m (syntax highlighting fixup automation)
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(3 intermediate revisions by 2 users not shown)
Line 107:
{ „mypath” }
{ „filtered” }
{ „pidstring” }
{ „myfilename” }
{ „mycommand” }
{ „editedlist” }
{ „foundflag” }
{ „aktfilename” }
{ „neworiginalname” }
 
</syntaxhighlight>
 
=={{header|Peri}}==
<syntaxhighlight lang="peri">
###sysinclude standard.uh
###sysinclude args.uh
###sysinclude list.uh
###sysinclude str.uh
###sysinclude io.uh
###define SEPARATOR 9
#g argc 3 < { "." }{ 2 argv } sto mypath
@mypath 'd inv istrue { ."The given directory doesn't exist! Exited.\n" end }
6 '- pidstr sto pidstring
@mypath getdir { ."Cannot load the dir! Aborted.\n" end } sto mydir
mypath per // Ha nem per-jelre végződik, kiegészíti vele.
10 mem sto aktstr
10 mem sto aktfilename
10 mem sto neworiginalname
"dr" sto types
1 mem !maximize sto szep
@szep 0 SEPARATOR inv []
@mydir ~r @mydir ~d + sto elemszám
//@elemszám 300 [[mem]] sto tömb
@elemszám 1 [[mem]] sto tömb
zero index
types {~ @mydir {~?~} <-~ {{ #g
1 sto() aktstr~
@aktstr 0 {~?~} #k uppercase inv []
#s @szep sum aktstr
{{}} #g !(#s) !trim dup sum aktstr inv mem
@szep sum aktstr
@mydir {~?~} {{}} getfilename sum aktstr
@aktstr @index [[tömb]]=
#g ++() index
}}
~}
"/tmp/peridiredit_tempfile-" sto myfilename
#s
@pidstring sum myfilename
".txt" sum myfilename
@tömb @myfilename listtofile! // print the list into a temporary file
"EDITOR" env sto mycommand
" " sum mycommand
@myfilename sum mycommand
 
@mycommand shell // execute the command
 
@myfilename filetolist sto editedlist
//@editedlist [[print]]! end
 
tömb~ externalloop: {{ // Loop for the original list
#g {{}} @[[tömb]] ~ inv { {{<}} } // If empty lines occured...
zero foundflag
editedlist~ {{ // loop for the edited list
// searching for the originaltype and originalnumber:
#g
{{}} [[editedlist]][0] {{}}§externalloop [[tömb]][0] != { {{<}} }
SEPARATOR {{}} 1 [[editedlist]][_] sto uj
SEPARATOR {{}}§externalloop 1 [[tömb]][_] sto er
#s @er @uj != { @er inv mem @uj inv mem {{<}} }
 
SEPARATOR {{}} 2 [[editedlist]][_] -- sto uj // trim the NL char at the end of the string
SEPARATOR {{}}§externalloop 2 [[tömb]][_] sto er
#s @er @uj != {
aktfilename @mypath = @er sum aktfilename
neworiginalname @mypath = @uj sum neworiginalname
@aktfilename @neworiginalname rename
."Renamed : " @aktfilename printnl
." ==> " @neworiginalname printnl
}
@er inv mem @uj inv mem
one foundflag
}} // editedlist~
@foundflag inv { // Nincs meg a file vagy dir. Ekkor le kell törölni:
{{}} [[tömb]][0] 'D #g == { // directory
SEPARATOR {{}} 2 [[tömb]][_] sto er
aktfilename @mypath #s = @er sum aktfilename @er inv mem
@aktfilename rmdir
."Deleted : " @aktfilename sprintnl
{{<}}
}
{{}} [[tömb]][0] 'R #g == { // Regular file
SEPARATOR {{}} 2 [[tömb]][_] sto er
aktfilename @mypath #s = @er sum aktfilename @er inv mem
@aktfilename removefile
."Deleted : " @aktfilename sprintnl
{{<}}
}
}
}} // tömb~
@myfilename removefile
end
 
{ „er” }
{ „uj” }
{ „szep” }
{ „types” }
{ „index” }
{ „mydir” }
{ „tömb” }
{ „mypath” }
{ „aktstr” }
{ „elemszám” }
{ „pidstring” }
{ „myfilename” }
Line 346 ⟶ 457:
}
}</syntaxhighlight>
 
=={{header|RPL}}==
This program, written in User RPL, can modify the name of one or more objects - variable or program, including itself - in the current directory, but cannot delete any of them: RPL "full-line" editor does not allow to identify which name(s) are removed from the list.
{{works with|HP|48G}}
≪ <span style="color:red">"VIDIR"
{ { "OBJ: " "?" 5 } }
{ }</span>
VARS <span style="color:red">1</span> →LIST DUP
INFORM VARS
→ newnames oldnames
≪ '''IF''' newnames SIZE oldnames SIZE == '''THEN'''
<span style="color:red">1</span> oldnames SIZE '''FOR''' j
oldnames j GET
DUP RCL
<span style="color:red">"'~tmp"</span> j + STR→ STO
PURGE
'''NEXT'''
<span style="color:red">1</span> oldnames SIZE '''FOR''' j
<span style="color:red">"'~tmp"</span> j + STR→
DUP RCL
newnames j GET STO
PURGE
'''NEXT'''
'''END'''
≫ ≫ '<span style="color:blue">VIDIR</span>' STO
 
=={{header|Wren}}==
Line 359 ⟶ 495:
 
This has been written to work on Linux but should work on other platforms with minor changes.
<syntaxhighlight lang="ecmascriptwren">import "os" for Process
import "io" for Directory, File
import "./fmt" for Fmt
9,476

edits