Vidir: Difference between revisions

From Rosetta Code
Content added Content deleted
(vidir, dir, edit)
 
No edit summary
Line 4: Line 4:


The original "vidir" was written in Perl, and it is the part of the socalled "moreutils" package, whomabout you can read in details at here: https://joeyh.name/code/moreutils/
The original "vidir" was written in Perl, and it is the part of the socalled "moreutils" package, whomabout you can read in details at here: https://joeyh.name/code/moreutils/

A bit more detailed specification from the vidir program itself:

'''Vidir allows editing of the contents of a directory in a text editor. If no directory is specified, the current directory is edited. When editing a directory, each item in the directory will appear on its own numbered line. These numbers are how vidir keeps track of what items are changed. Delete lines to remove files from the directory, or edit filenames to rename files.
'''




=={{header|Furor}}==
=={{header|Furor}}==

Revision as of 02:15, 11 June 2020

Vidir is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Create the famous "vidir" progam in your favorite programming language!

The original "vidir" was written in Perl, and it is the part of the socalled "moreutils" package, whomabout you can read in details at here: https://joeyh.name/code/moreutils/

A bit more detailed specification from the vidir program itself:

Vidir allows editing of the contents of a directory in a text editor. If no directory is specified, the current directory is edited. When editing a directory, each item in the directory will appear on its own numbered line. These numbers are how vidir keeps track of what items are changed. Delete lines to remove files from the directory, or edit filenames to rename files.


Furor

<lang Furor>

      1. sysinclude dir.uh
      2. define SEPARATOR 9
  1. g argc 3 < { "." }{ 2 argv } sto mypath

@mypath 'd !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 // If the end is not a '/' char, then add to... 10 mem sto aktfilename 10 mem sto neworiginalname tömb @mydir dirlist filtered tömb SEPARATOR [ #s 0 [-] "R" != 0 [-] "D" != #g & { dropline }{ 2 dropfield 2 dropfield } getline ] "/tmp/furordiredit_tempfile-" sto myfilename

  1. s

@pidstring sum myfilename ".txt" sum myfilename filtered @myfilename listtofile // print the list into a temporary file "EDITOR" env sto mycommand " " sum mycommand @myfilename sum mycommand @mycommand shell // execute the command editedlist @myfilename filetolist filtered SEPARATOR externalloop: ![ // Loop for the original list [-?] !{ dropline } // If empty lines occured...

  1. s

zero foundflag editedlist SEPARATOR ![ // Loop for the edited list // searching for the originaltype and originalnumber: 0 [-] 0 [-]§externalloop != { dropline } 1 [-] 1 [-]§externalloop != { dropline } 2 [-] 2 [-]§externalloop != { 2 [-] sbr §aktfilenamecreate neworiginalname @mypath = 2 [-]§externalloop sum neworiginalname @neworiginalname @aktfilename rename ."Renamed  : " @neworiginalname print ." ==> " @aktfilename printnl } one foundflag [>] ] // end for the editedlist-loop @foundflag !{ // No file or dir. In this case it must be deleted: 0 [-]§externalloop "D" == { // directory 2 [-] sbr §aktfilenamecreate @aktfilename rmdir ."Deleted  : " @aktfilename printnl dropline } 0 [-]§externalloop "R" == { // regular file 2 [-] sbr §aktfilenamecreate @aktfilename removefile ."Deleted  : " @aktfilename printnl dropline } }

] // End of the loop for the original list

@myfilename removefile end aktfilenamecreate: aktfilename @mypath = sum aktfilename rts

{ „mydir” } { „tömb” } { „mypath” } { „filtered” } { „pidstring” } { „myfilename” } { „mycommand” } { „editedlist” } { „foundflag” } { „aktfilename” } { „neworiginalname” }

</lang>