open next file in the folder

Started by: user3 voices10 posts

hello

when you open an image file with Windows XP Image Viewer, and you click ENTER, it opens the next (in alphabetical order) image file that exists in the current folder

can Emeditor do the same with txt files ?

to open the next file in the current folder using a key shortcut (maybe not ENTER, but some else)?

thanks
Hi user,

You could write a macro to view the next text file in the current folder by pressing a shortcut key.
can you tell me please how that macro should be
thanks
This is an example of the macro that opens the next .txt file in the same folder as the opened file.


// This macro opens the next ".txt" file in the current folder.
//
sFolder = document.Path;
if( sFolder != "" ){
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFolder(sFolder);
fc = new Enumerator(f.files);
sItem = "";
for (; !fc.atEnd(); fc.moveNext()) {
if( fc.item().name == document.Name ) {
for( fc.moveNext(); !fc.atEnd(); fc.moveNext()) {
n = fc.item().name.lastIndexOf(".");
if( n != -1 ){
if( fc.item().name.slice( n ) == ".txt" ){
sPath = sFolder + "" + fc.item().name;
try {
editor.OpenFile( sPath );
}
catch(e){
}
break;
}
}
}
break;
}
}
}

thanks and what are the hotkeys to view the next/previous txt file?
You can assign any shortcut key from the configuration properties > Keyboard tab. You can select this macro in the My Macros category, and then assign a new key.

does this work for the 'previous' txt file as well?
thanks
No, it doesn't work with previous text file.
Prev-file version...

// This macro opens the prev ".txt" file in the current folder.
//
sFolder = document.Path;
if( sFolder != "" ) {
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFolder(sFolder);
fc = new Enumerator(f.files);
sItem = "";
for (; !fc.atEnd(); fc.moveNext()) {
if( fc.item().name == document.Name ) {
try {
editor.OpenFile( sPath );
}
catch(e) {
}
break;
}
else {
n = fc.item().name.lastIndexOf(".");
if( n != -1 && fc.item().name.slice( n ) == ".txt" )
sPath = sFolder + "" + fc.item().name;
}
}
}
that is very useful thanks
but why it appears not well formatted? can you format it as the previous script?
thanks

10 posts in this topic