Re: Creating Folders with file name
Luca wrote:
> I have a problem to be solved.
> I have some files into a folder; every file has the same first 15 char.
> I need a batch that,
A DOS batch program? This will be probably hard, but I think you do not
mean that.
> creates a new folder into a specific path, with these 15 char as a
> folder name, and move all files from the old folder to the new one.
>
> Is it possible?
>
> I hope you can understand this unusual request.
<snip>
The way I understand it, it is possible in Euphoria.
You didn't write what platform you are using, the following program is
tested on Win 98 with the exw.exe 2.4 interpreter:
include file.e -- for dir()
function get_15 (sequence source_folder)
-- in : name of the folder, that contains the concerning files
-- out: first 15 characters, that all these files have in common
object list
sequence name
list = dir(source_folder)
if atom(list) then
puts(1, "Error - folder not found: " & source_folder)
abort(1)
end if
if length(list) < 3 then
puts(1, "Error - folder is empty: " & source_folder)
abort(1)
end if
name = list[3][D_NAME]
if length(name) < 15 then
puts(1, "Error - file name shorter than 15 characters: " & name)
abort(1)
end if
return name[1..15]
end function
sequence source_folder, specific_path, target_folder
integer n
----------------------------------
source_folder = "c:\\temp"
specific_path = "d:\\temp"
----------------------------------
n = length(source_folder )
if n > 0 and source_folder[n] != '\\' then
source_folder &= '\\'
end if
n = length(specific_path)
if n > 0 and specific_path[n] != '\\' then
specific_path &= '\\'
end if
target_folder = specific_path & get_15(source_folder)
system("md " & target_folder, 2)
system("move " & source_folder & "*.* " & target_folder, 2)
Regards,
Juergen
|
Not Categorized, Please Help
|
|