By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,852 Members | 2,198 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,852 IT Pros & Developers. It's quick & easy.

How to open folder ?!

viktorijakup
P: 10
Hi !!!

This script must open folder, and I must view empty opened folder...!!!
I work in "Far manager".

Now this script only create folder...

Expand|Select|Wrap|Line Numbers
  1.  
  2. @rem = '--*-Perl-*--
  3. @echo off
  4. if "%OS%" == "Windows_NT" goto WinNT
  5. perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
  6. goto endofperl
  7. :WinNT
  8. perl -x -S %0 %*
  9. if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
  10. if %errorlevel% == 9009 echo You do not have Perl in your PATH.
  11. if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
  12. goto endofperl
  13. @rem ';
  14. #!/usr/bin/perl
  15. use warnings;
  16. use strict;
  17. use File::Path;
  18. use Cwd;
  19. use File::Copy;
  20. use File::Spec::Functions;
  21. #hardcoded 
  22. my $FP = 'Y:\graphics_qc';
  23. my $TP = 'Y:\plot_db';
  24. my ($from_file, $to_file) = ($ARGV[0], $ARGV[0]);
  25. my $cwd = `cd`;
  26. chomp $cwd;
  27. my ($from_dir, $to_dir) = ($cwd, $cwd);
  28. #rename dir part
  29. $to_dir =~ s/^\Q$FP\E/$TP/;
  30. mkpath($to_dir);
  31. chdir $to_file;
  32. exit 0;
  33.  
  34. __END__
  35. :endofperl
  36.  
  37.  
Regards !!!

Viki
Sep 22 '08 #1
Share this Question
Share on Google+
8 Replies


nithinpes
Expert 100+
P: 410
If you want to physically open the folder (get the view of folder contents), use:
Expand|Select|Wrap|Line Numbers
  1. system("start $to_dir");  # this will open folder in win explorer
  2.  
Else, if you want to open the folder to read its contents(files) inside Perl script, use opendir() command.
Expand|Select|Wrap|Line Numbers
  1. opendir(DIR,"$to_dir") or die "failed to open:$!";
  2. while(<DIR>) { # read through contents of folder
  3.  
  4.  
Sep 22 '08 #2

viktorijakup
P: 10
Hi !!!

Thank you for answer !!!

Expand|Select|Wrap|Line Numbers
  1.      1. system("start $to_dir"); # this will open folder in win explorer  
I need the same opening folder in "Far manager".

:)


Regards !!!

Viki






If you want to physically open the folder (get the view of folder contents), use:
Expand|Select|Wrap|Line Numbers
  1. system("start $to_dir");  # this will open folder in win explorer
  2.  
Else, if you want to open the folder to read its contents(files) inside Perl script, use opendir() command.
Expand|Select|Wrap|Line Numbers
  1. opendir(DIR,"$to_dir") or die "failed to open:$!";
  2. while(<DIR>) { # read through contents of folder
  3.  
  4.  
Sep 22 '08 #3

numberwhun
Expert Mod 2.5K+
P: 3,503
I don't know about anyone else, but I have no idea what "Far Manager" is and have never heard of it. If it is an external program, then that is up to you to figure out. Otherwise, please explain what your needs are a little clearer.

Regards,

Jeff
Sep 22 '08 #4

nithinpes
Expert 100+
P: 410
I do not know about "Far Manager" either. However, if you know of a method to open a file/folder in Far manager through command prompt, then you should be able to do it using the same command inside system() in your script.
Sep 22 '08 #5

KevinADC
Expert 2.5K+
P: 4,059
I have a funny feeling he means File Manager.....
Sep 22 '08 #6

Icecrack
Expert 100+
P: 174
hey guys,

http://www.farmanager.com/

if its in the default then its should be

Expand|Select|Wrap|Line Numbers
  1. system(`c:\program files\far\far.exe`);
Sep 23 '08 #7

KevinADC
Expert 2.5K+
P: 4,059
looks like the old DOS interface I used to work with more than 15 years ago.
Sep 23 '08 #8

Icecrack
Expert 100+
P: 174
just to help this fella out i thought ill put in some command line argv


Expand|Select|Wrap|Line Numbers
  1.  /?   This help.
  2.  /a   Disable display of characters with codes 0 - 31 and 255.
  3.  /ag  Disable display of pseudographics characters.
  4.  /8   Forces FAR to work in ANSI (non-Unicode) console.
  5.  /e[<line>[:<pos>]] <filename>
  6.       Edit the specified file.
  7.  /i   Set small (16x16) icon for FAR console window.
  8.  /p[<path>]
  9.       Search for "common" plugins in the directory, specified by <path>.
  10.  /co  Forces FAR to load plugins from the cache only.
  11.  /rc  Restore console windows settings upon exiting FAR.
  12.  /u <username>
  13.       Allows to have separate settings for different users.
  14.  /v <filename>
  15.       View the specified file. If <filename> is -, data is read from the stdin.
  16.  /x   Disable exception handling.
Sep 23 '08 #9

Post your reply

Sign in to post your reply or Sign up for a free account.