Reading the name of a directory
Hi all,
I need to read the names of all files and directories available in a folder stored on my PC.
I would be thankful if someone could point be to a class and its method which is best suited for this to be done.
thanks in advance,
@debug
d@mn me and my inability to correctly type in words.
but yes i ment File.
It has a listFiles() method and an isDirectory()
method. With those two and a loop you should be able to do it.
Lima
Message was edited by:
LimaBravo -- trying to type d@mn without it being filtered :S
Similar Messages
-
My iPod Shuffle won't read the name of playlists or songs
I got my first iPod shuffle 4GB... everything's working fine but just when I click and hold the centre button it won't tell me the names of the song... or when I try to change playlists it will tell me "playlist 1... playlist 2... playlist 3" instead of the names of the playlists. Though I can see the names in my iTune.
Can anyone help me...? Thanks a lot.. I was actually really looking forward to this name-reading function..
CheersThank you so much - yes it will read the names of the songs and playlist now! Thanks a lot for your help, without your answer i probably won't be able to figure it out myself. Cheers!
-
Need help creating a script to read the name of a folder (which is the AD Username) and adding that name into the permissions of that folder.
I have over 100 folders which I need to add the AD user to read and write to their own folder
Hope you guys understand what I meanJust to add, Mac in intergrated into AD and all I need is help in creating the script
Thanks -
Error while reading file name in a directory
Hi,
I am trying to read all the file names within a directory, however I get the below error while running the code.
Run-time error '5':
Invalid procedure call or argument
The actual path is "Q:\Budget\Historical Budgets\FY15\*.xls*"
and ThisWorkbook.Sheets(1).Range("A1").Value = FY15 in my excel sheet.
"Below is the code I am using"
Dim file As Variant
file = Dir("Q:\Budget\Historical Budgets\" & ThisWorkbook.Sheets(1).Range("A1").Value & "\*.xls*")
If file = "" Then
MsgBox "no files"
Exit Sub
Else
' ... else, count the files
x = 0
Do While file <> ""
x = x + 1
file = Dir
<---- I get the error at this line.
Loop
End If
Could you please help me to solve this problem
Regards, HiteshDo you want to generate a list of all files in a folder, in your spreadsheet? If so, please try this sample code?
Option Explicit
Private cnt As Long
Private arfiles
Private level As Long
Sub Folders()
Dim i As Long
Dim sFolder As String
Dim iStart As Long
Dim iEnd As Long
Dim fOutline As Boolean
arfiles = Array()
cnt = -1
level = 1
sFolder = "C:\Users\Excel\Desktop\Coding\Microsoft Excel\Work Samples\"
ReDim arfiles(2, 0)
If sFolder <> "" Then
SelectFiles sFolder
Application.DisplayAlerts = False
On Error Resume Next
Worksheets("Files").Delete
On Error GoTo 0
Application.DisplayAlerts = True
Worksheets.Add.Name = "Files"
With ActiveSheet
For i = LBound(arfiles, 2) To UBound(arfiles, 2)
If arfiles(0, i) = "" Then
If fOutline Then
Rows(iStart + 1 & ":" & iEnd).Rows.Group
End If
With .Cells(i + 1, arfiles(2, i))
.Value = arfiles(1, i)
.Font.Bold = True
End With
iStart = i + 1
iEnd = iStart
fOutline = False
Else
.Hyperlinks.Add Anchor:=.Cells(i + 1, arfiles(2, i)), _
Address:=arfiles(0, i), _
TextToDisplay:=arfiles(1, i)
iEnd = iEnd + 1
fOutline = True
End If
Next
.Columns("A:Z").ColumnWidth = 5
End With
End If
'just in case there is another set to group
If fOutline Then
Rows(iStart + 1 & ":" & iEnd).Rows.Group
End If
Columns("A:Z").ColumnWidth = 5
ActiveSheet.Outline.ShowLevels RowLevels:=1
ActiveWindow.DisplayGridlines = False
End Sub
Sub SelectFiles(Optional sPath As String)
Static FSO As Object
Dim oSubFolder As Object
Dim oFolder As Object
Dim oFile As Object
Dim oFiles As Object
Dim arPath
If FSO Is Nothing Then
Set FSO = CreateObject("Scripting.FileSystemObject")
End If
If sPath = "" Then
sPath = CurDir
End If
arPath = Split(sPath, "\")
cnt = cnt + 1
ReDim Preserve arfiles(2, cnt)
arfiles(0, cnt) = ""
arfiles(1, cnt) = arPath(level - 1)
arfiles(2, cnt) = level
Set oFolder = FSO.GetFolder(sPath)
Set oFiles = oFolder.Files
For Each oFile In oFiles
cnt = cnt + 1
ReDim Preserve arfiles(2, cnt)
arfiles(0, cnt) = oFolder.Path & "\" & oFile.Name
arfiles(1, cnt) = oFile.Name
arfiles(2, cnt) = level + 1
Next oFile
level = level + 1
For Each oSubFolder In oFolder.Subfolders
SelectFiles oSubFolder.Path
Next
level = level - 1
End Sub
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it. -
How to read the "Name" field from document library in workflow?
Hi,
The task I'm trying to accomplish looks pertty simple: I need to read a value of the item's "Name" field inside the workflow. I try to do it using LookupSPListItem and GetDynamicValueProperties activities. I can get value of the "Title"
field, also I created custom field and can read it too.
But the "Name" field always comes empty.
I guess I need to use some tricky syntax or this field has some different "internal name"?
The workflow is designed in VS 2013.Thank you. Looks correct, since when I enter this path (FileLeafRef) into GetDynamicValueProperties
and change Entity Type to list of documents it changes to Name
automatically.
But somehow it doesn't work too. (:
I also tried LinkFilenameNoMenu and LinkFilename
- same result.
EDIT: Solved. :)
Looks like FileLeafRef is not loaded by default by LookupSPListItem, so you have to pass this property name via
Properties collection. The bad news is that in this case other properties won't be loaded if you didn't add them to this collection.
Anyway, it works. :) -
How to read the name of .csv file from a particular folder using Oracle.
Gurus,
I have a folder called 'data_dir' in Oracle Server and it contains 10 different .csv files and the name of the each file is being suffixed by date and time(24 hrs format).
First i need to read all the file names then i have to process those files by UTL_FILE to load the data into a relational table.
Is there any mechanism is available in Oracle to read the file names?
(In this case all the 10 different csv file names)
If so, then please help me accomplish this.
Thanks in advance.
Regards,
Venugopal.KIs there any mechanism is available in Oracle to read the file names?Sounds to me like you need to use External Tables (*not* utl_file).
http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/et_concepts.htm -
Reading the name without comma
Hi All,
I got a query to resolve.
the issue is that for example i have a name with a comma (sudheer,)
i need to read only the name sudheer without the comma .what is the logic for this.
Good answers will be rewarded points.
Thanks in Advance.
Regards,
sudheer.d@mn me and my inability to correctly type in words.
but yes i ment File.
It has a listFiles() method and an isDirectory()
method. With those two and a loop you should be able to do it.
Lima
Message was edited by:
LimaBravo -- trying to type d@mn without it being filtered :S -
Read the name of a parent node of a (static) Tree UI in WebDynPro Abap
hi Experts,
I have a tree control UI that has two levels of nodes from the Root node. Year & Month. Inside the Month Node there is always only one leaf that is called Current Schedule. User clicks on Current Schedule to view the Current Schedule. This could be any month's Current Schedule of the User's choice.
Thus, I need to know which month's current schedule is chosen by the user. My tree UI is an adaptation from WDT_TREE example from Std SAP example programs. For the chosen month to be known, I have to go up in the context node hierarchy by one level? (something like, get_parent of) from the current leaf. I am not sure how would i do it. Any pointers would be greatly helpful. I tried to pick up ideas from couple of tutorials and bunch of forum posts but I did not get anywhere.
The key to my requirement is just going up one level in the tree and get to know the 'name' of that node. That will tell me the Month of the User's choice.
Thanks in advance for your helpful answers/pointersThanks Bala Duvvuri,
Could you please elaborate a bit more on your tip. I am a fledgling OO abapper not 'really' knowing as much OO as I should ..!!
By the way,I found out, I could apply the same OnAction method in the WDT_TREE example shown at the final leaf level to the node level as well to read the text of Month Node. It worked out and it meets my purpose with a rider..!
In order to get this Month node text for the selected 'Current Schedule' leaf, User have to click on the Month Node that opens the Current Schedule Leaf. If they clicked on the triangle beside the node, it still opens the Month Node to reveal the Current Schedule leaf, but the Month name wont be captured until User expressly clicked on Month Node first or the Folder Icon associated with it..!!
In other words, User cannot click on the left side triangle; if they did to reach the Current Schdule, the program wont work properly. This is no good, though i could talk my way through with the User to accept this. But technically i know it is possible to know the month name from a given Current Schedule leaf in the tree,though dont know how ..!!
Your bit more detailed reply would help me implement the more elegant solution than pushing the user to accept what i did.
As I await your reply i shall try to pick up from your tip.
In the meanwhile my tree has grown ..!! to have two more nodes, in which the contents need to be dynamically populated. Guess I am in for a long haul with the Tree UI
Looking to hear more. Thanks heaps again. -
PLSQL to Read File Names from a Directory
Interested in a sample of PLSQL code that reads from a UNIX directory the list of files in the directory for further processing in the program.
Thank you.
Monathis should do the trick
http://asktom.oracle.com/pls/ask/f?p=4950:8:804140
greetings
Freek D'Hooge
Interested in a sample of PLSQL code that reads from a UNIX directory the list of files in the directory for further processing in the program.
Thank you.
Mona -
Read the names of the files in ABAP program that runs in the background
Hello,
I have a program that uploads information from file on application server.
What I can't figure still is how to get the <b>names </b>of the files that are in <b>specific directory</b>.
There is an other application that will post those files into this directory. I wont to get file names and file types from this directory and put it into an internal table.
File names are changing based on date and version.
Please keep in mind that the program runs in the background, (presentation server is not included in the process)
Thanks in advance,
MilanHi,
one epossible solution that i have used is:
1. Create an operating system comand with transaction SM69
command OS OS-command Parameter
ZDIR Windows NT Customer cmd.exe /C dir &
2. Call Functionmodul
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
COMMANDNAME = 'ZDIR'
ADDITIONAL_PARAMETERS = P_PARA1
OPERATINGSYSTEM = SY-OPSYS
TARGETSYSTEM = SY-HOST
DESTINATION =
STDOUT = 'X'
STDERR = 'X'
TERMINATIONWAIT = 'X'
TRACE =
IMPORTING
STATUS = G_OK
EXITCODE =
TABLES
EXEC_PROTOCOL = GTBL_PROTO
EXCEPTIONS
NO_PERMISSION = 1
COMMAND_NOT_FOUND = 2
PARAMETERS_TOO_LONG = 3
SECURITY_RISK = 4
WRONG_CHECK_CALL_INTERFACE = 5
PROGRAM_START_ERROR = 6
PROGRAM_TERMINATION_ERROR = 7
X_ERROR = 8
PARAMETER_EXPECTED = 9
TOO_MANY_PARAMETERS = 10
ILLEGAL_COMMAND = 11
WRONG_ASYNCHRONOUS_PARAMETERS = 12
CANT_ENQ_TBTCO_ENTRY = 13
JOBCOUNT_GENERATION_ERROR = 14
OTHERS = 15
3. Loop at GTBL_PROTO and make your coding with the filenames
Hope this helps
Regards
Bernd -
How to read the name of a PDF file? - function module
Hi,
I have <b>some individual pdf documents in my desktop</b>.I need to <b>bulk-upload it to the content server and document related information to the SAP-DB</b>.
Need your guidance.
Regards,
John.try this code it will convert file to PDF file
REPORT ZWARUN_CONVERSION_PDF .
***********Tables***************
TABLES:VBRK.
***********Data Declaration***************
DATA: LV_NUMBYTES TYPE I,
LV_SPOOLNO TYPE TSP01-RQIDENT.
DATA:C_LAYOUT LIKE PRI_PARAMS-PAART VALUE 'X_65_132', "Layout
C_X TYPE C VALUE 'X'.
DATA: NUMBYTES TYPE I,
CANCEL.
***************Internal table of Pdf************
DATA: IT_PDF LIKE TLINE OCCURS 10 WITH HEADER LINE.
DATA:BEGIN OF IT_VBRK OCCURS 2,
FKART LIKE VBRK-FKART,
FKTYP LIKE VBRK-FKTYP,
VBTYP LIKE VBRK-VBTYP,
END OF IT_VBRK.
SELECTION-SCREEN BEGIN OF BLOCK BLK WITH FRAME.
SELECT-OPTIONS: S_BUKRS FOR VBRK-BUKRS,
S_GJAHR FOR VBRK-GJAHR.
SELECTION-SCREEN END OF BLOCK BLK .
PARAMETERS:
spoolno like tsp01-rqident,
DOWNLOAD AS CHECKBOX DEFAULT 'X',
P_FILE LIKE RLGRAP-FILENAME DEFAULT 'C:\warun1.pdf'.
START-OF-SELECTION.
SELECT FKART
FKTYP
VBTYP
INTO TABLE IT_VBRK
FROM VBRK
WHERE BUKRS IN S_BUKRS
AND GJAHR IN S_GJAHR.
END-OF-SELECTION.
DATA: LK_PARAMS TYPE PRI_PARAMS,
LV_VALID.
if not p_mailid is initial.
All the parameters passed are constants, so exceptions
doesn't get raised
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
IMMEDIATELY = ' '
LAYOUT = C_LAYOUT "'X_65_132'
NO_DIALOG = C_X
IMPORTING
OUT_PARAMETERS = LK_PARAMS
VALID = LV_VALID.
IF LV_VALID <> SPACE .
NEW-PAGE PRINT ON PARAMETERS LK_PARAMS NO DIALOG.
*--To display the final report
PERFORM PRINT_REPORT.
NEW-PAGE PRINT OFF.
*---To convert the download to PDF
PERFORM CONV_TO_PDF_DOWNLOAD.
PERFORM DOWNLOAD.
ENDIF.
endif.
*--To display the final report
PERFORM PRINT_REPORT.
*& Form print_report
FORM PRINT_REPORT .
*write:/ 'I will do it' color 4.
write:/ 'Yes' color 4.
write:/ 'we will do it' color 4.
write:/ 'lets talk abt changing life style' color 4.
write:/'By warun'.
LOOP AT IT_VBRK.
WRITE:/ IT_VBRK-FKART,IT_VBRK-FKTYP,IT_VBRK-VBTYP.
ENDLOOP.
ENDFORM. " print_report
*& Form conv_to_pdf_download
FORM CONV_TO_PDF_DOWNLOAD .
CLEAR IT_VBRK.
WAIT UP TO 2 SECONDS.
LV_SPOOLNO = SY-SPONO.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = LV_SPOOLNO
NO_DIALOG = ''
DST_DEVICE =
PDF_DESTINATION =
IMPORTING
PDF_BYTECOUNT = LV_NUMBYTES
PDF_SPOOLID = pdfspoolid
LIST_PAGECOUNT =
BTC_JOBNAME = jobname
BTC_JOBCOUNT = jobcount
TABLES
PDF = IT_PDF.
ENDFORM. " conv_to_pdf_download
*& Form download
FORM DOWNLOAD .
download PDF file ***********
CHECK DOWNLOAD = 'X'.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
BIN_FILESIZE = LV_NUMBYTES
FILENAME = P_FILE
FILETYPE = 'BIN'
IMPORTING
ACT_FILENAME = P_FILE
FILESIZE = LV_NUMBYTES
CANCEL = CANCEL
TABLES
DATA_TAB = IT_PDF.
IF CANCEL = SPACE.
WRITE: / LV_NUMBYTES, P_FILE.
ENDIF.
ENDFORM. " download -
Under the old version of Mail, when an e-mail was read, the name of the sender was greted out so that I knew I had read that email. This does not seem to happen under the new Mail thaqt came with Lion. Help!?
Chuck Humphrey
[email protected]
303-997-2755Kirk,
Thanks again for your suggestions. No, I don't get an
error message. In fact nothing happens. My name and
key are typed in and from what I understand, once you
do that with a real key it directs you to the
registration page. When I get done entering the
information the window just sits there without any
button or option to continue.
QT Pro is already in the QT (non-pro) you installed and the key (which is a hash of your name in part) allows the Pro features to work.
No redirect, internet, nothing like that. As such many people have activated and think they haven't. Just look at the menu items and see if the "Pro" logo is shown next to a few (which are greyed out and not available without Pro). If not you are done. -
I have a bunch of files in a directory. How to read just the filename from the directory.
Following code will read the contents in a directory into a temporary table. The code comes from "expert one-on-one" from thomas kyte.
Remember to set the java privileges correctly for the directorys you want to create the list from.
greetings
Freek D
CREATE GLOBAL TEMPORARY TABLE DIR_LIST
( FILENAME VARCHAR2(255) )
ON COMMIT DELETE ROWS
CREATE OR REPLACE
AND COMPILE java source named "DirList"
AS
import java.io.*;
import java.sql.*;
public class DirList{
public static void getList(String directory) throws SQLException{
File path = new File( directory );
String[] list = path.list();
String element;
for(int i = 0; i < list.length; i++){
element = list;
#sql {
INSERT INTO DIR_LIST (FILENAME)
VALUES (:element) };
CREATE OR REPLACE PROCEDURE GET_DIR_LIST (
P_DIRECTORY IN VARCHAR2)
AS
LANGUAGE JAVA
NAME 'DirList.getList( java.lang.String )';
BEGIN
DBMS_JAVA.GRANT_PERMISSION (
USER,
'java.io.FilePermission',
'c:\temp',
'read');
END;
EXEC get_dir_list( 'c:\temp' );
SELECT *
FROM DIR_LIST
WHERE ROWNUM < 5; -
MDM Sender Channel - reading file name
Hi all,
Is there any simple way to read the name of file sent by MDM when I am using MDM sender adapter ?
I know if it's file sender channel, then we can read file name by writing a UDF. But just wondering about MDM sender adapter.
Regards,
-ShankarHi Paul,
you can always delete this inside your mapping:
for instance trim the first 13 letters from /home/example
then if your directory is always the same you'll have a filename only
Regards,
michal -
Modifying the name of a file generated by a servlet
Hi!
I have a servlet called co.com.SomeStaff who reads a binary file from the server an responses it to the client, but the name that appears when the browser tries to save it is "co.com.SomeStaff" and I need the "SomeBinariFile.exe" instead. How can iI do this?
I've tried to modify the Headers but....
I need it as soon as posible.
Thanks All.I assume you are creating the file as a java.io.File object. Under those circumstances you should be able to specify the name and target directory when you save it:File f = new File(directory+System.getProperty("file.separator")+filename);Or, if you have already named it:
f.renameTo("file.txt");Actually, now I look at it, I may have totally misunderstood what you are trying to do there- are you naming it right in the hyperlink?
Maybe you are looking for
-
Anyone that spends a decent amount of time listening to music through headphones knows what a wide range of sound quality and comfort you can get from different models of headphones. I spend a good portion of my days with my headphones on to help blo
-
Transferring a number to a different account and contract question
Hello, So today I got offered a phone from where I work. I'm in a family plan with 4 phones, i only need one of the lines transferred to my boss's account, but will doing this break the contract that I'm in right now? because I don't want to pay $17
-
I have CC and while attempting Light Effects, the Light Effects Layer will appear in the layers panel, but the option bar will not appear and neither will the Properties panel. All my preferences are set correct, and my computer has a compatible vide
-
Issue with fullscreen gl and screen corruption...
Hi. I am running dual monitors on a radeon x1300 with the ati catalyst drivers (version 8.7-2). Whenever i attempt to run a gl program fullscreen my displays corrupt. in windowed mode they work fine. I think this might be an issue with fullscreen t
-
Hi, i have a problem with the emulator ( on one account of mac os x, other works ok ). The Java ME SDK 3.0 yesterday worked, today doesn't. When i try to run something the IDE windows looses focus, builds the app ok, but no emulator windows appears.