URGENT : getting attribute of files in a directory
Hello.
I use oracle 8i and I want to get attributes of files inside a directory like the "Modified" attribute which indicates the time of creation of the file.
How can I do this ?
Thank you very much.
Tom Kytes has an example with java callout
Directory List including modify date and times - casting the date problem
http://asktom.oracle.com/pls/ask/f?p=4950:8:5492560634257383293::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:7506780031005,
Similar Messages
-
Hi,
How to retrieve the attributes of file(creation date) stored in server using ABAP Program.
Which Unix command is used to retrieve creation date with year?
Plz do needful.Hi,
How to retrieve the attributes of file(creation date) stored in server using ABAP Program.
Which Unix command is used to retrieve creation date with year?
Plz do needful. -
Getting list of files from Unix directory inclding files frm sub-directries
Hi All,
I am trying to use Fm 'SUBST_GET_FILE_LIST' and
'RZL_READ_DIR_LOCAL' for getting a list of all files in a Unix directory including files from sub-directories.
In the first case I am getting an Exception called 'Access Error'
and when I use the 2nd FM, I am not getting any output.
Is there a special way to use these FMs.
Kindly help.
Regds,
Shweta[url http://java.sun.com/developer/JDCTechTips/2003/tt0122.html#1]READING FILES FROM JAVA ARCHIVES (JARS)
-
Getting list of files in root directory
I have seen many forum talking somewhat on this subject but I always see them using c: (for windows) as the example directory. I need to write this so that I can go to a Unix directory.
Example:
I want to go to the root directory from where I am....I would use runtime.exec(), right? But does the runtime actually go to that directory or just run the exec?
If there was a "name" such as c: in unix like windows it would be easier. But, I can not just say the name of the directory is / to get in there and check out the files. So, really what I want to do is if someone is not in the particular directory I want to be able to go to the root directory and check files there, then go to another directory and check the files there, etc.
I have a hard time explaining things so hopefully someone will get me.
Thanks.But the trouble I am running in to is that I want the
root directory in Unix, which would be /. I can not
not just put that as the directory, can i?You can if you spell it out:
/export/home/thefunnyrootename
... or use:
String sysprop = System.getProperty("whatever property");
File f = new File(sysprop);... To determine which you want, SDK v1.3.1 docs for System.getProperty():
getProperties
public static Properties getProperties()
Determines the current system properties.
First, if there is a security manager, its checkPropertiesAccess
method is called with no arguments. This may result in a security
exception.
The current set of system properties for use by the
getProperty(String) method is returned as a Properties object.
If there is no current set of system properties, a set of system
properties is first created and initialized. This set of system
properties always includes values for the following keys:
Key Description of Associated Value
java.version Java Runtime Environment version
java.vendor Java Runtime Environment vendor
java.vendor.url Java vendor URL
java.home Java installation directory
java.vm.specification.version Java Virtual Machine specification version
java.vm.specification.vendor Java Virtual Machine specification vendor
java.vm.specification.name Java Virtual Machine specification name
java.vm.version Java Virtual Machine implementation version
java.vm.vendor Java Virtual Machine implementation vendor
java.vm.name Java Virtual Machine implementation name
java.specification.version Java Runtime Environment specification version
java.specification.vendor Java Runtime Environment specification vendor
java.specification.name Java Runtime Environment specification name
java.class.version Java class format version number
java.class.path Java class path
java.ext.dirs Path of extension directory or directories
os.name Operating system name
os.arch Operating system architecture
os.version Operating system version
file.separator File separator ("/" on UNIX)
path.separator Path separator (":" on UNIX)
line.separator Line separator ("\n" on UNIX)
user.name User's account name
user.home User's home directory
user.dir User's current working directory
Note that even if the security manager does not permit the getProperties
operation, it may choose to permit the getProperty(String) operation.
Returns:
the system propertiesThrows:
SecurityException - if a security manager exists and its
checkPropertiesAccess method doesn't allow access to the system
properties.See Also:
setProperties(java.util.Properties), SecurityException,
SecurityManager.checkPropertiesAccess(), Properties~Bill -
Get list of files in a directory
Hello everybody,
working with Oracle 9.2 I have created a directory and i would like to implement in pl/sql a procedure that return the list of files contained.
Anybody know the general solution for this matter?
Thanks in advanceTom Kyte has an example:
Directory List including modify date and times -
How to get all files in one directory
Hi there,
is there any way to get all the files in one directory?
e.g. a method
File[] getAllFiles(String directory){
Thank youJust out of interest, which part of the File API was confusing?
http://java.sun.com/j2se/1.5.0/docs/api/index.html
If you look down the left-hand side, you'll see a frame listing "All File". If you select "File" from that list, it opens up the API in the right-hand frame. Quite near the top you'll find "listFiles".
I only ask as this (and other questions easily answered by looking at the API) are frequently asked. Did you overlook it when you read the API or did you just not read it?
I really want to know. I think there is scope to cater for that behaviour within this site. A nice API finder would be good; something more intelligent than the search function (which people use less frequently even than the API docs). -
Getting files of a directory in app server
Hi,
Is there any FM or method to get all the files of a directory ( in the application server )if its path is given as input.
It should list the file name, creation date and also size.
Thanks,
Nawaz.Hi,
you can use the follow code:
REPORT zdirtest.
DATA lv_dir TYPE rsmrgstr-path VALUE '/usr/sap/trans/data'.
DATA: wa_files TYPE rsfillst,
it_files LIKE TABLE OF wa_files.
START-OF-SELECTION.
CALL FUNCTION 'SUBST_GET_FILE_LIST'
EXPORTING
dirname = lv_dir
filenm = '*'
TABLES
file_list = it_files
EXCEPTIONS
access_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE /1 'Error! :-('.
ELSE.
LOOP AT it_files INTO wa_files.
WRITE: /1 wa_files-name,
wa_files-len.
ENDLOOP.
ENDIF.
However the field <b>MTIME</b> from the structure <b>RSFIILST</b> is not filled correctly with the number of seconds since 1970 because the field is defined to small.
So you can't list the correct modification date and time.
If you really need this, you should take a look in the Report <b>RSWATCH0</b> in the form <b>fill_file_list</b>.
This form fills an internal table with the correctly modification date and time.
Regards,
Stefan -
Tlog files in startup directory
Running wls 6.1, I get the following files in the directory where
weblogic is running (which is the parent directory of the config dir):
drwxrwxr-x 3 farnaz staff 512 Aug 28 17:33 tmp_ejbcosmo7003/
-rw-rw-r-- 1 farnaz staff 4 Aug 28 17:32 tse.0000.tlog
-rw-rw-r-- 1 farnaz staff 4 Aug 28 17:32 tse.heur.0000.tlog
where tse is the name of my weblogic server.
Is there a way to configure the server so that this files are written to
a directory I want instead of startup dir?farnaz <[email protected]> wrote:
Running wls 6.1, I get the following files in the directory where
weblogic is running (which is the parent directory of the config dir):
drwxrwxr-x 3 farnaz staff 512 Aug 28 17:33 tmp_ejbcosmo7003/
-rw-rw-r-- 1 farnaz staff 4 Aug 28 17:32 tse.0000.tlog
-rw-rw-r-- 1 farnaz staff 4 Aug 28 17:32 tse.heur.0000.tlog
where tse is the name of my weblogic server.
Is there a way to configure the server so that this files are written
to
a directory I want instead of startup dir?check out my post about:
Running two instances on same machine WL6.0/WL6.1(.tlog files)
it will solve this problem...
Eric -
What i get is only the directories and files that in other nodes. But i have also files on the root directory and i never
get them. This is a screenshot of my program after i got the content of my ftp. I'm using treeView to display my ftp content:
You can see two directories from the root but no files on the root it self. And in my ftp server host i have files in the root direcory.
This is the method i'm using to get the directory listing:
public IEnumerable<FTPListDetail> GetDirectoryListing(string rootUri)
var CurrentRemoteDirectory = rootUri;
var result = new StringBuilder();
var request = GetWebRequest(WebRequestMethods.Ftp.ListDirectoryDetails, CurrentRemoteDirectory);
using (var response = request.GetResponse())
using (var reader = new StreamReader(response.GetResponseStream()))
string line = reader.ReadLine();
while (line != null)
result.Append(line);
result.Append("\n");
line = reader.ReadLine();
if (string.IsNullOrEmpty(result.ToString()))
return new List<FTPListDetail>();
result.Remove(result.ToString().LastIndexOf("\n"), 1);
var results = result.ToString().Split('\n');
string regex =
@"^" + //# Start of line
@"(?<dir>[\-ld])" + //# File size
@"(?<permission>[\-rwx]{9})" + //# Whitespace \n
@"\s+" + //# Whitespace \n
@"(?<filecode>\d+)" +
@"\s+" + //# Whitespace \n
@"(?<owner>\w+)" +
@"\s+" + //# Whitespace \n
@"(?<group>\w+)" +
@"\s+" + //# Whitespace \n
@"(?<size>\d+)" +
@"\s+" + //# Whitespace \n
@"(?<month>\w{3})" + //# Month (3 letters) \n
@"\s+" + //# Whitespace \n
@"(?<day>\d{1,2})" + //# Day (1 or 2 digits) \n
@"\s+" + //# Whitespace \n
@"(?<timeyear>[\d:]{4,5})" + //# Time or year \n
@"\s+" + //# Whitespace \n
@"(?<filename>(.*))" + //# Filename \n
@"$"; //# End of line
var myresult = new List<FTPListDetail>();
foreach (var parsed in results)
var split = new Regex(regex)
.Match(parsed);
var dir = split.Groups["dir"].ToString();
var permission = split.Groups["permission"].ToString();
var filecode = split.Groups["filecode"].ToString();
var owner = split.Groups["owner"].ToString();
var group = split.Groups["group"].ToString();
var filename = split.Groups["filename"].ToString();
var size = split.Groups["size"].Length;
myresult.Add(new FTPListDetail()
Dir = dir,
Filecode = filecode,
Group = group,
FullPath = CurrentRemoteDirectory + "/" + filename,
Name = filename,
Owner = owner,
Permission = permission,
return myresult;
And then this method to loop over and listing :
private int total_dirs;
private int searched_until_now_dirs;
private int max_percentage;
private TreeNode directories_real_time;
private string SummaryText;
private TreeNode CreateDirectoryNode(string path, string name , int recursive_levl )
var directoryNode = new TreeNode(name);
var directoryListing = GetDirectoryListing(path);
var directories = directoryListing.Where(d => d.IsDirectory);
var files = directoryListing.Where(d => !d.IsDirectory);
total_dirs += directories.Count<FTPListDetail>();
searched_until_now_dirs++;
int percentage = 0;
foreach (var dir in directories)
directoryNode.Nodes.Add(CreateDirectoryNode(dir.FullPath, dir.Name, recursive_levl+1));
if (recursive_levl == 1)
TreeNode temp_tn = (TreeNode)directoryNode.Clone();
this.BeginInvoke(new MethodInvoker( delegate
UpdateList(temp_tn);
percentage = (searched_until_now_dirs * 100) / total_dirs;
if (percentage > max_percentage)
SummaryText = String.Format("Searched dirs {0} / Total dirs {1}", searched_until_now_dirs, total_dirs);
max_percentage = percentage;
backgroundWorker1.ReportProgress(percentage, SummaryText);
percentage = (searched_until_now_dirs * 100) / total_dirs;
if (percentage > max_percentage)
SummaryText = String.Format("Searched dirs {0} / Total dirs {1}", searched_until_now_dirs, total_dirs);
max_percentage = percentage;
backgroundWorker1.ReportProgress(percentage, SummaryText);
foreach (var file in files)
TreeNode file_tree_node = new TreeNode(file.Name);
file_tree_node.Tag = "file" ;
directoryNode.Nodes.Add(file_tree_node);
numberOfFiles.Add(file.FullPath);
return directoryNode;
Then updating the treeView:
DateTime last_update;
private void UpdateList(TreeNode tn_rt)
TimeSpan ts = DateTime.Now - last_update;
if (ts.TotalMilliseconds > 200)
last_update = DateTime.Now;
treeViewMS1.BeginUpdate();
treeViewMS1.Nodes.Clear();
treeViewMS1.Nodes.Add(tn_rt);
ExpandToLevel(treeViewMS1.Nodes, 1);
treeViewMS1.EndUpdate();
And inside a backgroundworker do work how i'm using it:
var root = Convert.ToString(e.Argument);
var dirNode = CreateDirectoryNode(root, "root", 1);
e.Result = dirNode;
And last the FTPListDetail class:
public class FTPListDetail
public bool IsDirectory
get
return !string.IsNullOrWhiteSpace(Dir) && Dir.ToLower().Equals("d");
internal string Dir { get; set; }
public string Permission { get; set; }
public string Filecode { get; set; }
public string Owner { get; set; }
public string Group { get; set; }
public string Name { get; set; }
public string FullPath { get; set; }
Now the main problem is that when i list the files and directories and display them in the treeView it dosen't get/display
the files in the root directory. Only in the sub nodes.
I will see the files inside hello and stats but i need also to see the files in the root directory.
1. How can i get and list/display the files of the root directory ?
2. For the test i tried to add to a List<string> the items in var files to see if i get the root files at all.
This is what i tried in the CreateDirectoryNode before it i added:
private List<string> testfiles = new List<string>();
Then after var files i did:
testfiles.Add(files.ToList()
But this is wrong. I just wanted to see in testfiles what items i'm getting in var files in the end of the process.
Both var files and directoryListing are IEnumerable<FTPListDetail> type.
The most important is to make the number 1 i mentioned and then to do number 2.Risa no.
What i mean is this. This is a screenshot of my ftp server at my host(ipage.com).
Now this is a screenshot of my program and you can see that in my program i have only the directories hello stats test but i don't have the files in the root: htaccess.config swp txt 1.txt 2.png....all this files i don't have it on my treeView.
What i want it to be is that on my program on the treeView i will also display the files like in my ftp server.
I see in my program only the directories and the files in the directories but i don't see the files on the root directory/node.
I need it to be like in my ftp server i need to see in my program the htaccess 1.txt 2.png and so on.
So what i wrote in my main question is that in the var files i see this files of the root directory i just don't know to add and display them in my treeView(my treeView is treeViewMS1).
I know i checked in my program in the method CreateDirectoryNode i see in the first iteration of the recursive that var files contain this root files i just dont know how to add and display them in my treeView.
On the next iterations when it does the recursive it's adding the directories hello stats test and the files in this directories but i need it to first add the root files. -
How can I get a file to copy all of the files in a directory except itself and the source of the copy function will be the directory the final program is in? This application must be in Lab View 8.
you mean something like this (see below)?
Now you may have to implement code to check if the destination folder exists and to create it, etc. But if you use the Front Panel Control to select the destination folder, it should be okay.
Not the best implementation, mind you but you'll get the idea..
Message Edited by JoeLabView on 04-18-2007 03:43 PM
Attachments:
copy folder contents.PNG 10 KB -
How to get the current executing file/itself absolute directory?
hellooo,
gentlemen/lady, how to get the current executing file/itself absolute directory?
thanks
Hello,
you can get the real path information of the JSP through the servlet context:
http://java.sun.com/products/servlet/2.2/javadoc/index.html
javax.servlet
Interface ServletContext
Method getRealPath
Christian Plenagl
Developer Relations Engineer
BEA Support
[email protected] (alex mok) wrote:
>hellooo,
>
>gentlemen/lady, how to get the current executing file/itself absolute
>directory?
>
>thanks
-
Get file list from directory(t.code: AL11).
Hi Frnds,
i need to get the list of file for particular directory from t.code AL11,
is there any Function Module to display the list of File from the directory in executable program,
i have directory like '/home/im3/hrintf/processed/..... ' and now i need to get the list of file from that directory,
the list is available in t.code AL11( standard program :RSWATCH0 ).
pls suggest me with relevant FM or relevant logic.
Thank you.
Regards
Ramesh MHi
use this code i have checked its working fine
Data:
w_itab type table of EPSFILI,
w_dirnam type EPSF-EPSDIRNAM.
w_dirnam = 'C:\usr\sap\E6S\DVEBMGS00\work'.
CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
EXPORTING
dir_name = w_dirnam
* FILE_MASK = ' '
* IMPORTING
* DIR_NAME =
* FILE_COUNTER =
* ERROR_COUNTER =
tables
dir_list = w_itab
* EXCEPTIONS
* INVALID_EPS_SUBDIR = 1
* SAPGPARAM_FAILED = 2
* BUILD_DIRECTORY_FAILED = 3
* NO_AUTHORIZATION = 4
* READ_DIRECTORY_FAILED = 5
* TOO_MANY_READ_ERRORS = 6
* EMPTY_DIRECTORY_LIST = 7
* OTHERS = 8
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
write: 'test'.
Thanks
Viquar Iqbal -
How to get the file size (in bytes) for all files in a directory?
How to get the file size (in bytes) for all files in a directory?
The following code does not work. isFile() does NOT recognize files as files but only as directories. Why?
Furthermore the size is not retrieved correctly.
How do I have to code it otherwise? Is there a way of not converting f-to-string-to-File again but iterate over all file objects instead?
Thank you
Peter
java.io.File f = new java.io.File("D:/todo/");
files = f.list();
for (int i = 0; i < files.length; i++) {
System.out.println("fn=" + files);
if (new File(files[i]).isFile())
System.out.println("file[" + i + "]=" + files[i] + " size=" + (new File(files[i])).length() ); }pstein wrote:
...The following code does not work. Work?! It does not even compile! Please consider posting code in the form of an SSCCE in future.
Here is an SSCCE.
import java.io.File;
class ListFiles {
public static void main(String[] args) {
java.io.File f = new java.io.File("/media/disk");
// provides only the file names, not the path/name!
//String[] files = f.list();
File[] files = f.listFiles();
for (int i = 0; i < files.length; i++) {
System.out.println("fn=" + files);
if (files[i].isFile()) {
System.out.println(
"file[" +
i +
"]=" +
files[i] +
" size=" +
(files[i]).length() );
}Edit 1:
Also, in future, when posting code, code snippets, HTML/XML or input/output, please use the code tags to retain the indentation and formatting. To do that, select the code and click the CODE button seen on the Plain Text tab of the message posting form. It took me longer to clean up that code and turn it into an SSCCE, than it took to +solve the problem.+
Edited by: AndrewThompson64 on Jul 21, 2009 8:47 AM -
How do U to get the names of all files in a directory?
Is there a simple way to get all names of the files in a directory and put them in an array of Strings? Sounds simple, but I don't have a clue how to do this. Thanks.
Hi Kindoo,
Create a instance of File object using the path of the Directory
File fileDir = new File(directoryPath);
To get the List of all the files in the directory use
String[] strFiles = fileDir.list();
This will solve your problem,
Cheers
Nagaraj -
How to get the Attributes of file ?
Hi Guru,
How to find of the Attributes of file in sap u2018 AL11u2019.
The file attribute details need to show in the report.
If any idea plz. Help me.
Regards,
SubashThe attributes you can see from , go tofile part level in the directory. Place the cursor on file name and choose menu option
Log file ->attributes.
Edited by: Raja gurrala on Jul 31, 2009 1:16 PM
Maybe you are looking for
-
User Exit - adding defualt WBS Element in addi.tab for IW31 - Servi.Order
I am facing a problem with adding WBS Element in Addit.Data tab for Service Order creation using IW31. At the time of creating service order using TCODE IW31, I have to maintian default values like WBS ELEMENT, for this I am using a USER EXIT "IWO100
-
After Effects & Effects Plugins
On the verge of getting After Effects. I am going to d/load the trial but i wanted to ask this first. Have been looking at various tutorials on the CreativeCow site for some things that i want to use After FX for. There a lots of effects that have th
-
Wiki calendar path!!
Hi! I'm working on ical server, wiki calendar for group! As I know it is not possible to send invitation if calendar is based on wiki, but may be it is possible to change path for wiki calendar so it could look on calendar which made no server __uids
-
After upgrade to OS X Yosemite my ringtones are not recognized on my i phone 5s
after upgrading to latest OS X Yosemite my ringtone makers new tones will not transfer to the tones files although they show up in the ringtone documents on my macBook air
-
have just installed Mavericks OS from Mountain Lion. Download OK. Restart OK. Sign-in failing. Server Error message. Any suggestions